Created
November 3, 2020 21:16
-
-
Save OnorioCatenacci/26506d8c0eb7d54b20f2416118b15a0a to your computer and use it in GitHub Desktop.
Initial state of TicTacToe Game
This file contains 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 TicTacToeGame --------------------------- | |
VARIABLE boardPositions, turn | |
tokens == {"X","O","V","-"} (* V == "Vacant", - == "Doesn't matter" *) | |
row == <<tokens, tokens, tokens>> | |
grid == <<row, row, row>> | |
col_1_Win(token) == << | |
<<token, "-", "-">>, | |
<<token, "-", "-">>, | |
<<token, "-", "-">> | |
>> | |
col_2_Win(token) == << | |
<<"-", token, "-">>, | |
<<"-", token, "-">>, | |
<<"-", token, "-">> | |
>> | |
col_3_Win(token) == << | |
<<"-", "-", token>>, | |
<<"-", "-", token>>, | |
<<"-", "-", token>> | |
>> | |
row_1_Win(token) == << | |
<<token, token, token>>, | |
<<"-", "-", "-">>, | |
<<"-", "-", "-">> | |
>> | |
row_2_Win(token) == << | |
<<"-", "-", "-">>, | |
<<token, token, token>>, | |
<<"-", "-", "-">> | |
>> | |
row_3_Win(token) == << | |
<<"-", "-", "-">>, | |
<<"-", "-", "-">>, | |
<<token, token, token>> | |
>> | |
dexterWin(token) == << | |
<<token, "-", "-">>, | |
<<"-", token, "-">>, | |
<<"-", "-", token>> | |
>> | |
sinisterWin(token) == << | |
<<"-", "-", token>>, | |
<<"-", token, "-">>, | |
<<token, "-", "-">> | |
>> | |
PlayerWin(token) == \/ boardPositions = col_1_Win(token) | |
\/ boardPositions = col_2_Win(token) | |
\/ boardPositions = col_3_Win(token) | |
\/ boardPositions = row_1_Win(token) | |
\/ boardPositions = row_2_Win(token) | |
\/ boardPositions = row_3_Win(token) | |
\/ boardPositions = dexterWin(token) | |
\/ boardPositions = sinisterWin(token) | |
GameInit == /\ boardPositions \in << | |
<<"V","V","V">>, | |
<<"V","V","V">>, | |
<<"V","V","V">> | |
>> | |
/\ turn = 0 | |
Player1Win == PlayerWin("X") | |
Player2Win == PlayerWin("O") | |
============================================================================= | |
\* Modification History | |
\* Last modified Tue Nov 03 15:51:31 EST 2020 by ocatenacci | |
\* Created Mon Nov 02 10:31:22 EST 2020 by ocatenacci |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment