[iagno] Search to a constant depth



commit 974698703f3aa124e4ee7f09426d38b26551a620
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Sun Sep 8 12:13:00 2013 -0500

    Search to a constant depth
    
    Towards the game the search depth jumps from 3/5/7 (easy/normal/hard) to
    15/17/19, which takes several minutes to complete and causes the game to
    hang during that time.  This is making it pretty much impossible to
    finish a game of Iagno unless one player is completely eliminated before
    that point.
    
    Search instead to a constant depth of 3/5/7 throughout the game.  It
    might make sense to go a bit deeper towards the end of the game when
    playing on Hard, but 3/5/7 should work fairly well.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=668553

 src/computer-player.vala |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
---
diff --git a/src/computer-player.vala b/src/computer-player.vala
index 91c3b74..b3b27c6 100644
--- a/src/computer-player.vala
+++ b/src/computer-player.vala
@@ -60,19 +60,19 @@ public class ComputerPlayer
             return;
         }
 
+        var depth = 7 - (3 - level) * 2;
+        var tiles_remaining = 64 - game.n_tiles;
+
         /* Choose a strategy based on how close to the end we are.
          * At the end of the game try and maximise the number of tokens.
          * Near the end try and push for a win.
          * For the rest of the game try and maximise everything.
          */
-        var depth = 64 - game.n_tiles;
         var strategy = Strategy.BEST;
-        if (depth <= 17 - (3 - level) * 2)
+        if (tiles_remaining <= depth + 10)
             strategy = Strategy.PERFECT;
-        else if (depth <= 19 - (3 - level) * 2)
+        else if (tiles_remaining <= depth + 12)
             strategy = Strategy.VICTORY;
-        else
-            depth = 7 - (3 - level) * 2;
 
         /* Choose a location to place by building the tree of possible moves and
          * using the minimax algorithm to pick the best branch with the chosen


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]