diff options
author | dozens | 2024-06-20 09:17:06 -0600 |
---|---|---|
committer | dozens | 2024-06-20 09:17:06 -0600 |
commit | c7b2c982004e350f5e3032321baadfc9021b6bad (patch) | |
tree | 3f8883c94bed5a1f847cf60cb11207ca53946c67 /lib/mill.fnl | |
parent | ce09973e7cacccdc779f91b8e6e48a520b9f9f4d (diff) |
🗄️ big tidy up
- isolate core game logic and move it to src/game.fnl - main.fnl should be just the ui now - move all table funcs into lib/table - move all (1) string funcs into lib/string - move all game funcs into lib/game/
Diffstat (limited to 'lib/mill.fnl')
-rw-r--r-- | lib/mill.fnl | 41 |
1 files changed, 0 insertions, 41 deletions
diff --git a/lib/mill.fnl b/lib/mill.fnl deleted file mode 100644 index f9c8673..0000000 --- a/lib/mill.fnl +++ /dev/null @@ -1,41 +0,0 @@ -(local {: contains} (require :lib.contains)) - -(fn get-candidates [all-mills next-move] - "a list of mills that contain next-move" - (icollect [_ mill (ipairs all-mills)] (if (contains mill next-move) mill))) - -(fn any [t] - "take a list of booleans, returns true if any of them are true" - (accumulate [acc false - i x (ipairs t)] - (or acc x))) - -(fn move-mills [moves-list] - (icollect [_ moves (ipairs moves-list)] - (let [player (. moves 1)] - (accumulate [acc true - _ m (ipairs moves)] - (and acc (not= m 0) (= player m)))))) - -(fn candidate-moves [candidates moves] - "Just turning board spaces into player moves" - (icollect [_ spaces (ipairs candidates)] - (icollect [_ space (ipairs spaces)] - (. moves space)))) - -(fn mill-at? [all-mills current-moves move] - "Is there a mill at this move?" - (let [candidates (get-candidates all-mills move) - my-moves (candidate-moves candidates current-moves) - my-mills (move-mills my-moves) - result (any my-mills)] - result)) - -{: mill-at? - ;; not for consumption, - ;; just for testing: - : get-candidates - : candidate-moves - : move-mills - : any - } |