summaryrefslogtreecommitdiff
path: root/strategies
diff options
context:
space:
mode:
authorRobby Zambito <contact@robbyzambito.me>2022-01-21 18:26:46 -0500
committerRobby Zambito <contact@robbyzambito.me>2022-01-21 18:26:46 -0500
commit0026e5937a3f91a1551dee15bc7482ffee1735d6 (patch)
tree22d328c06829f131d33af02ed47027357646820b /strategies
parent0846d554b20df412aa16c7e250c400daee82dd59 (diff)
Made apply_move return the number of flipped spaces.
This will return zero for invalid moves, and non-zero for valid moves. This means we can continue to use the result of this as a boolean. Also created a new Scheme primitive which returns the number of tiles flipped by a given move. Created two strategies. One which picks the move that flips the most tiles in the current turn, and one which flips the least.
Diffstat (limited to 'strategies')
-rw-r--r--strategies/least-flipped.scm6
-rw-r--r--strategies/most-flipped.scm6
2 files changed, 12 insertions, 0 deletions
diff --git a/strategies/least-flipped.scm b/strategies/least-flipped.scm
new file mode 100644
index 0000000..7b4bc0c
--- /dev/null
+++ b/strategies/least-flipped.scm
@@ -0,0 +1,6 @@
+(use-modules (srfi srfi-1))
+
+(first (sort (valid-moves)
+ (lambda (a b)
+ (< (flipped-by-move a)
+ (flipped-by-move b)))))
diff --git a/strategies/most-flipped.scm b/strategies/most-flipped.scm
new file mode 100644
index 0000000..0976709
--- /dev/null
+++ b/strategies/most-flipped.scm
@@ -0,0 +1,6 @@
+(use-modules (srfi srfi-1))
+
+(first (sort (valid-moves)
+ (lambda (a b)
+ (> (flipped-by-move a)
+ (flipped-by-move b)))))