Created
June 6, 2025 11:50
-
-
Save robknight/3aae179a0eca3464224d111b0ee0d7a6 to your computer and use it in GitHub Desktop.
tic-tac-toe pod
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
| player1_turn(move_pod) = AND( | |
| Equal(old_game_pod["next_turn"], SELF["player1"]) | |
| Equal(move_pod["_signer"], SELF["player1"]) | |
| DictContains(SELF["board"], move_pod["place"], SELF["player_1_token"]) | |
| Equal(SELF["next_turn"], SELF["player2"]) | |
| ) | |
| player2_turn(move_pod) = AND( | |
| Equal(old_game_pod["next_turn"], SELF["player2"]) | |
| Equal(move_pod["_signer"], SELF["player2"]) | |
| DictContains(SELF["board"], move_pod["place"], SELF["player_2_token"]) | |
| Equal(SELF["next_turn"], SELF["player1"]) | |
| ) | |
| valid_turn_taken(move_pod, old_game_pod) = OR( | |
| player1_turn(move_pod, old_game_pod) | |
| player2_turn(move_pod, old_game_pod) | |
| ) | |
| same_or_move_target(old_game_pod, move_pod, position_key, position_name_key) = OR( | |
| Equal(?old_game_pod[?position_key], SELF[?position_key]) | |
| Equal(move_pod["position"], SELF[?position_name_key]) | |
| ) | |
| new_game(player1_key, player2_key, next_turn_key) = AND( | |
| ValueOf(SELF["empty"], "") | |
| Equal(SELF["a1"], SELF["empty"]) | |
| Equal(SELF["a2"], SELF["empty"]) | |
| Equal(SELF["a3"], SELF["empty"]) | |
| Equal(SELF["b1"], SELF["empty"]) | |
| Equal(SELF["b2"], SELF["empty"]) | |
| Equal(SELF["b3"], SELF["empty"]) | |
| Equal(SELF["c1"], SELF["empty"]) | |
| Equal(SELF["c2"], SELF["empty"]) | |
| Equal(SELF["c3"], SELF["empty"]) | |
| // Player identities must be part of public arguments | |
| Equal(SELF["player1"], SELF[?player1_key]) | |
| Equal(SELF["player2"], SELF[?player2_key]) | |
| // Player 1 goes first | |
| Equal(SELF["next_turn"], SELF[?player1_key]) | |
| ) | |
| check_for_invalid_changes(old_game_pod, move_pod) = AND( | |
| same_or_move_target(old_game_pod, move_pod, "a1", "a1_name") | |
| same_or_move_target(old_game_pod, move_pod, "a2", "a2_name") | |
| same_or_move_target(old_game_pod, move_pod, "a3", "a3_name") | |
| same_or_move_target(old_game_pod, move_pod, "b1", "b1_name") | |
| same_or_move_target(old_game_pod, move_pod, "b2", "b2_name") | |
| same_or_move_target(old_game_pod, move_pod, "b3", "b3_name") | |
| same_or_move_target(old_game_pod, move_pod, "c1", "c1_name") | |
| same_or_move_target(old_game_pod, move_pod, "c2", "c2_name") | |
| same_or_move_target(old_game_pod, move_pod, "c3", "c3_name") | |
| ) | |
| valid_move(old_game_pod, move_pod, private: old_board_state) = AND( | |
| // Constants | |
| ValueOf(SELF, "player_1_token", "X") | |
| ValueOf(SELF, "player_2_token", "O") | |
| ValueOf(SELF, "EMPTY", "") | |
| ValueOf(SELF["a1_name"], "a1") | |
| ValueOf(SELF["a2_name"], "a2") | |
| ValueOf(SELF["a3_name"], "a3") | |
| ValueOf(SELF["b1_name"], "b1") | |
| ValueOf(SELF["b2_name"], "b2") | |
| ValueOf(SELF["b3_name"], "b3") | |
| ValueOf(SELF["c1_name"], "c1") | |
| ValueOf(SELF["c2_name"], "c2") | |
| ValueOf(SELF["c3_name"], "c3") | |
| // Copy from earlier game state: | |
| Equal(SELF["player1"], old_game_pod["player1"]) | |
| Equal(SELF["player2"], old_game_pod["player2"]) | |
| // Tokens can only be placed in empty slots | |
| DictContains(old_game_pod["board"], move_pod["place"], SELF["EMPTY"]) | |
| valid_turn_taken(move_pod, old_game_pod) | |
| ) | |
| valid_game_board(player1_key, player2_key) = OR( | |
| new_game(?player1_key, ?player2_key, ?player1_key) | |
| valid_move(?player1_key, ?player2_key) | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment