Created
September 17, 2020 18:03
-
-
Save mrjoelkemp/28e1578a87d5995bf01d76cc40d4058e to your computer and use it in GitHub Desktop.
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
defmodule Game do | |
require Board | |
defstruct board: %Board{} | |
def is_complete?(%Game{ board: board } = game) do | |
Board.has_winner?(board) or Board.is_draw?(board) | |
end | |
end | |
defmodule Board do | |
# Positions with the x coord and y coord separated by an underscore | |
defstruct "0_0": "", "0_1": "", ... | |
def has_winner?(%Board{} = board) do | |
# All that logic to check for TicTacToe win states | |
end | |
def is_draw?(%Board{} = board) do | |
# All that logic to check for all positions taken with no winner | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment