[iagno] Optimisation.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [iagno] Optimisation.
- Date: Wed, 22 May 2019 13:01:38 +0000 (UTC)
commit 44d07a0ca8d4cd3c64b2f0d3de7635acc9e22f9d
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Wed May 8 20:21:41 2019 +0200
Optimisation.
src/computer-reversi.vala | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
---
diff --git a/src/computer-reversi.vala b/src/computer-reversi.vala
index cf5a5d8..8341c0b 100644
--- a/src/computer-reversi.vala
+++ b/src/computer-reversi.vala
@@ -45,9 +45,8 @@ private class ComputerReversiEasy : ComputerReversi
* * minimax / negamax / alpha-beta pruning
\*/
- protected override void get_possible_moves_sorted (GameState g, out List<PossibleMove?> moves)
+ protected override void sort_moves (ref List<PossibleMove?> moves)
{
- g.get_possible_moves (out moves);
moves.sort (compare_move);
}
@@ -91,9 +90,8 @@ private class ComputerReversiHard : ComputerReversi
* * minimax / negamax / alpha-beta pruning
\*/
- protected override void get_possible_moves_sorted (GameState g, out List<PossibleMove?> moves)
+ protected override void sort_moves (ref List<PossibleMove?> moves)
{
- g.get_possible_moves (out moves);
moves.sort_with_data (compare_move);
}
@@ -293,7 +291,8 @@ private abstract class ComputerReversi : ComputerPlayer
int16 a = LESS_THAN_NEGATIVE_INFINITY;
List<PossibleMove?> moves;
- get_possible_moves_sorted (g, out moves);
+ g.get_possible_moves (out moves);
+ sort_moves (ref moves);
/* Try each move using alpha-beta pruning to optimise finding the best branch */
foreach (PossibleMove? move in moves)
@@ -333,7 +332,8 @@ private abstract class ComputerReversi : ComputerPlayer
if (g.current_player_can_move)
{
List<PossibleMove?> moves;
- get_possible_moves_sorted (g, out moves);
+ g.get_possible_moves (out moves);
+ sort_moves (ref moves);
/* Try each move using alpha-beta pruning to optimise finding the best branch */
foreach (PossibleMove? move in moves)
@@ -365,5 +365,5 @@ private abstract class ComputerReversi : ComputerPlayer
}
protected abstract int16 calculate_heuristic (GameState g);
- protected abstract void get_possible_moves_sorted (GameState g, out List<PossibleMove?> moves);
+ protected abstract void sort_moves (ref List<PossibleMove?> moves);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]