[iagno] Add a fallback for buggy IA.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [iagno] Add a fallback for buggy IA.
- Date: Mon, 25 Feb 2019 21:02:08 +0000 (UTC)
commit 03aeaa042030b20166c221338ded98a46333d67b
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Mon Feb 25 21:57:12 2019 +0100
Add a fallback for buggy IA.
src/computer-player.vala | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
---
diff --git a/src/computer-player.vala b/src/computer-player.vala
index eb99725..96184b9 100644
--- a/src/computer-player.vala
+++ b/src/computer-player.vala
@@ -93,7 +93,16 @@ private class ComputerPlayer : Object
if (game.place_tile (x, y) == 0)
{
critical ("Computer chose an invalid move: %d,%d\n%s", x, y, game.to_string ());
- assert_not_reached ();
+
+ /* Has been reached, once. So let's have a fallback. */
+ uint8 new_x;
+ uint8 new_y;
+ random_select (game, out new_x, out new_y);
+ if (game.place_tile (new_x, new_y) == 0)
+ {
+ critical ("Computer chose an invalid move for the second time: %d,%d\n%s", new_x, new_y,
game.to_string ());
+ assert_not_reached ();
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]