-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMyBot.cs
54 lines (44 loc) · 1.57 KB
/
MyBot.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using System.Collections.Generic;
using System.Linq;
using Delver.CamelCup.External;
namespace Delver.CamelCup.MartinBots
{
public class MyBot : ICamelCupPlayer
{
public string GetPlayerName()
{
return "MyBotForUpload";
}
public void StartNewGame(int playerId, GameInfo info, GameState gameState)
{
}
public void InformAboutAction(int player, PlayerAction action, GameState gameState)
{
}
public void Winners(List<int> winners, GameState gameState)
{
}
public PlayerAction GetAction(GameState gameState)
{
var camelWins = gameState.GetCamelWins(out var money, 5);
var sum = (double)camelWins.Sum(x => x.Value);
var probability = camelWins.ToDictionary(x => x.Key, x => x.Value / sum);
var bettingCards = gameState.BettingCards
.GroupBy(x => x.CamelColor)
.ToDictionary(x => x.Key, y => y.Where(x => x.IsFree).Select(x => x.Value).DefaultIfEmpty(0).Max());
var bets = probability.ToDictionary(x => x.Key, x => x.Value * bettingCards[x.Key]);
var bestBet = bets.OrderByDescending(x => x.Value).First();
if (bestBet.Value > 1.0)
{
return new PlayerAction() { CamelAction = CamelAction.PickCard, Color = bestBet.Key };
}
return new PlayerAction() { CamelAction = CamelAction.ThrowDice };
}
public void Save()
{
}
public void Load()
{
}
}
}