[iagno] Make heuristic a table.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [iagno] Make heuristic a table.
- Date: Sat, 30 Mar 2019 11:09:28 +0000 (UTC)
commit de0e1c083c24b3c231ebb397ea23b18b75e73f9f
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Fri Mar 29 14:32:31 2019 +0100
Make heuristic a table.
src/computer-player.vala | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
---
diff --git a/src/computer-player.vala b/src/computer-player.vala
index 92e4991..2425067 100644
--- a/src/computer-player.vala
+++ b/src/computer-player.vala
@@ -47,16 +47,16 @@ private class ComputerPlayer : Object
private uint8 difficulty_level;
/* Value of owning each location */
- private const int [] heuristic = // TODO make int [,]
+ private const int [,] heuristic =
{
- 65, -3, 6, 4, 4, 6, -3, 65,
- -3, -29, 3, 1, 1, 3, -29, -3,
- 6, 3, 5, 3, 3, 5, 3, 6,
- 4, 1, 3, 1, 1, 3, 1, 4,
- 4, 1, 3, 1, 1, 3, 1, 4,
- 6, 3, 5, 3, 3, 5, 3, 6,
- -3, -29, 3, 1, 1, 3, -29, -3,
- 65, -3, 6, 4, 4, 6, -3, 65
+ { 65, -3, 6, 4, 4, 6, -3, 65 },
+ { -3, -29, 3, 1, 1, 3, -29, -3 },
+ { 6, 3, 5, 3, 3, 5, 3, 6 },
+ { 4, 1, 3, 1, 1, 3, 1, 4 },
+ { 4, 1, 3, 1, 1, 3, 1, 4 },
+ { 6, 3, 5, 3, 3, 5, 3, 6 },
+ { -3, -29, 3, 1, 1, 3, -29, -3 },
+ { 65, -3, 6, 4, 4, 6, -3, 65 }
};
/* Source ID of a pending move timeout */
@@ -343,7 +343,7 @@ private class ComputerPlayer : Object
{
for (uint8 y = 0; y < g.size; y++)
{
- int h = heuristic [y * g.size + x];
+ int h = heuristic [x, y];
if (g.get_owner (x, y) != g.current_color)
h = -h;
count += h;
@@ -402,7 +402,7 @@ private class ComputerPlayer : Object
moves.append (x * g.size + y);
int length = (int) moves.length ();
- if (length == 0)
+ if (length <= 0)
assert_not_reached ();
uint8 i = (uint8) Random.int_range (0, length);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]