This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "1.0.0", | |
"summary": "minMax TDD Kata", | |
"repository": "https://github.com/dschinkel/elm-minmax-kata.git", | |
"license": "MIT", | |
"source-directories": [ | |
"tests" | |
], | |
"exposed-modules": [ | |
"Example" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Solver exposing (..) | |
import Array exposing (fromList, get) | |
import List exposing (filter) | |
nextBestMove : List Char -> Int | |
nextBestMove gameNode = | |
3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it "next move wins for a row" <| | |
let | |
gameNode = | |
[ markerX, markerX, empty, empty, empty, empty, empty, empty, empty ] | |
cellThreeIndex = | |
2 | |
nextMove = | |
Solver.nextBestMove gameNode |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it "next move wins for a column" <| | |
let | |
gameNode = | |
[ markerX, empty, empty, markerX, empty, empty, empty, empty, empty ] | |
cellSevenIndex = | |
6 | |
nextMove = | |
Scorer.nextBestMove gameNode |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Scorer exposing (..) | |
import Array exposing (fromList, get, set) | |
-- below won't work, you can't do this in elm. You can't have two statements in the in of a let like this | |
nextBestMove : List Char -> Int | |
nextBestMove gameNode = | |
let | |
cells = | |
fromList gameNode |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nextBestMove gameNode = | |
let | |
cells = | |
fromList gameNode | |
nextGameState1 = | |
set 2 'X' cells | |
nextGameState2 = |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-- | |
Below shows some code commands that if entered into elm repl shows the output received | |
--} | |
import List | |
empty = ' ' | |
markerX = 'X' | |
markerO = 'O' | |
gameNode = [ [ markerX, empty, empty ], [ markerO, markerO, empty ], [ markerX, empty, empty ]] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Scorer exposing (..) | |
import Array exposing (fromList, get, set) | |
import List exposing (map) | |
import Maybe exposing (withDefault) | |
nextBestMove : List (List Char) -> Int | |
nextBestMove gameNode = | |
let |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
row1NextState = | |
set 2 'X' (withDefault (Array.initialize 3 (always ' ')) row1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
myAnswerArray = | |
Array.fromList ["S"] | |
|> Array.set 5279 "S" |