[iagno] Optimisation.



commit 40b736dc0736cadf4fa0ba7eb3505e3b67521e5a
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Sat May 4 17:25:50 2019 +0200

    Optimisation.

 src/computer-reversi.vala | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/src/computer-reversi.vala b/src/computer-reversi.vala
index 31664d2..94ad217 100644
--- a/src/computer-reversi.vala
+++ b/src/computer-reversi.vala
@@ -210,9 +210,11 @@ private class ComputerReversi : ComputerPlayer
         {
             for (uint8 y = 0; y < size; y++)
             {
+                bool is_current_color = g.is_current_color (x, y);
+
                 // heuristic
                 int16 h = heuristic [x, y];
-                if (!g.is_current_color (x, y))
+                if (!is_current_color)
                     h = -h;
                 count += h;
 
@@ -220,7 +222,7 @@ private class ComputerReversi : ComputerPlayer
                 int16 a = (int16) g.get_empty_neighbors (x, y);
                 if (a == 0) // completely surrounded
                     a = -2;
-                count += g.is_current_color (x, y) ? -a : a;
+                count += is_current_color ? -a : a;
             }
         }
         return count;


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