[iagno] Improve a bit more compare_move.



commit 40d8fbf7ce613c0d4e624d8329e41e5ee874cfa3
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Mon Jun 3 22:02:07 2019 +0200

    Improve a bit more compare_move.

 src/computer-reversi.vala | 5 ++++-
 src/game.vala             | 5 +++++
 2 files changed, 9 insertions(+), 1 deletion(-)
---
diff --git a/src/computer-reversi.vala b/src/computer-reversi.vala
index d4864ae..fd54575 100644
--- a/src/computer-reversi.vala
+++ b/src/computer-reversi.vala
@@ -120,7 +120,7 @@ private class ComputerReversiHard : ComputerReversi
         calculate_dir_heuristic (ref comparator, move.x, move.y, -1,  1, move.n_tiles_so);
         calculate_dir_heuristic (ref comparator, move.x, move.y, -1,  0, move.n_tiles_o );
         calculate_dir_heuristic (ref comparator, move.x, move.y, -1, -1, move.n_tiles_no);
-        return 2 * comparator + (int) heuristic [move.x, move.y];
+        return 2 * comparator + (int) heuristic [move.x, move.y] - 9 * (int) neighbor_tiles [move.x, move.y];
     }
 
     private inline void calculate_dir_heuristic (ref int comparator, uint8 x, uint8 y, int8 x_step, int8 
y_step, uint8 count)
@@ -245,10 +245,13 @@ private abstract class ComputerReversi : ComputerPlayer
     private const int16 NEGATIVE_INFINITY           = -32000;
     private const int16 LESS_THAN_NEGATIVE_INFINITY = -32001;
 
+    protected uint8 [,] neighbor_tiles;
+
     construct
     {
         size = game.size;
         move_randomly = game.initial_number_of_tiles + (size < 6 ? 2 : 4);
+        neighbor_tiles = game.copy_neighbor_tiles ();
     }
 
     /*\
diff --git a/src/game.vala b/src/game.vala
index ce58895..7eb2f86 100644
--- a/src/game.vala
+++ b/src/game.vala
@@ -706,6 +706,11 @@ private class Game : Object
 
     private uint8 [,] neighbor_tiles;
 
+    internal uint8 [,] copy_neighbor_tiles ()
+    {
+        return neighbor_tiles;
+    }
+
     private static void init_neighbor_tiles (uint8 size, out uint8 [,] neighbor_tiles)
     {
         neighbor_tiles = new uint8 [size, size];


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