Commit 64d9352d authored by Jonathan Michalon's avatar Jonathan Michalon
Browse files

Bot: optimise with get_remaining_pawn_count and use DOUBLE pawns

parent 09c7228b
......@@ -103,17 +103,19 @@ public class Bot : OVCCClient.Client
critical ("We were asked to place a pawn somewhere there is no tile");
return;
}
foreach (var o in tile.objects) {
if (player.place_pawn (OVCC.PawnKind.NORMAL, o, pos)) {
debug ("Placed pawn at %d %d", pos.x, pos.y);
break;
var kind = OVCC.PawnKind.NORMAL;
if (player.get_remaining_pawn_count (kind) == 0) {
kind = OVCC.PawnKind.DOUBLE;
}
if (player.get_remaining_pawn_count (kind) == 0) {
debug ("No pawn available");
} else {
foreach (var o in tile.objects) {
if (player.place_pawn (kind, o, pos)) {
debug ("Placed pawn at %d %d", pos.x, pos.y);
break;
}
}
/* we guess all pawns can go anywhere another can -- which isn't true
* using some extensions, but it doesn't matter that much. */
/* FIXME: this should probably also be asynchronous... */
// if (game.place_pawn (player.pawns.nth_data (0), o)) {
// break;
// }
}
game.turn_finished ();
}));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment