Designing the Game Boardλ︎
Using the REPL we can experiment with different ways to model the game board.
How to represent a cellλ︎
A cell is either going to be empty, or contain a nought or cross. For simplicity, we will start with three keywords
Representing the whole boardλ︎
We could just hard code the board as a vector of rows, with each row being a vector. In this example we set all the board cells to :empty
Generating a data structure to represet the game board
To create a row is simple to do using the repeat function to generate 3 :empty keywords and return them as a list
To make this a vector we can just wrap that in a vec function
To create three rows we just repeat the code above 3 times
We can use the above code in a function and replace 3 with a local name that takes the value of the argument passed in so lets write a game-board function.
If you need a quick break while modeling your game board, here is a very silly distraction
{% youtube %} https://youtu.be/0h9jN12QbdE