[iagno] Slow down the game
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [iagno] Slow down the game
- Date: Sun, 20 Oct 2013 03:22:36 +0000 (UTC)
commit d39ba1dfe4c24cf071136f16db2ec4e0b7d5321b
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Mon Oct 14 22:14:47 2013 -0500
Slow down the game
Give the player a breather after each move, so he has a chance to think.
https://bugzilla.gnome.org/show_bug.cgi?id=710122
src/computer-player.vala | 2 +-
src/iagno.vala | 22 +++++++++++++++-------
2 files changed, 16 insertions(+), 8 deletions(-)
---
diff --git a/src/computer-player.vala b/src/computer-player.vala
index 61ed277..a7ca0b4 100644
--- a/src/computer-player.vala
+++ b/src/computer-player.vala
@@ -35,7 +35,7 @@ public class ComputerPlayer : Object
private Game game;
/* Strength */
- private int level;
+ public int level { get; private set; }
/* Value of owning each location */
private static const int[] heuristic =
diff --git a/src/iagno.vala b/src/iagno.vala
index 386990f..c6c6aeb 100644
--- a/src/iagno.vala
+++ b/src/iagno.vala
@@ -234,7 +234,10 @@ public class Iagno : Gtk.Application
update_ui ();
- /* Get the computer to move after a delay (so it looks like it's thinking) */
+ /*
+ * Get the computer to move after a delay (so it looks like it's
+ * thinking - but only a short delay for the first move)
+ */
if (dark_computer != null)
computer_timer = Timeout.add (1000, computer_move_cb);
}
@@ -359,12 +362,17 @@ public class Iagno : Gtk.Application
update_ui ();
- /* Get the computer to move after a delay (so it looks like it's thinking) */
- if ((game.current_color == Player.LIGHT && light_computer != null) ||
- (game.current_color == Player.DARK && dark_computer != null))
- {
- computer_timer = Timeout.add (1000, computer_move_cb);
- }
+ /*
+ * Get the computer to move after a delay, so it looks like it's
+ * thinking. Make it fairly long so the human doesn't feel overwhelmed,
+ * but not so long as to become boring. Also, attempt to play faster at
+ * higher difficulties. (In actuality, Hard will take longer anyway
+ * since it must search deeper, but this compensates somewhat.)
+ */
+ if (game.current_color == Player.LIGHT && light_computer != null)
+ computer_timer = Timeout.add_seconds (5 - light_computer.level, computer_move_cb);
+ else if (game.current_color == Player.DARK && dark_computer != null)
+ computer_timer = Timeout.add_seconds (5 - dark_computer.level, computer_move_cb);
}
private bool computer_move_cb ()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]