Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Path: blob/master/04-Milestone Project - 1/03-Milestone Project 1 - Complete Walkthrough Solution.ipynb
Views: 648
Milestone Project 1: Full Walk-through Code Solution
Below is the filled in code that goes along with the complete walk-through video. Check out the corresponding lecture videos for more information on this code!
Step 1: Write a function that can print out a board. Set up your board as a list, where each index 1-9 corresponds with a number on a number pad, so you get a 3 by 3 board representation.
TEST Step 1: run your function on a test version of the board list, and make adjustments as necessary
Step 2: Write a function that can take in a player input and assign their marker as 'X' or 'O'. Think about using while loops to continually ask until you get a correct answer.
TEST Step 2: run the function to make sure it returns the desired output
Step 3: Write a function that takes in the board list object, a marker ('X' or 'O'), and a desired position (number 1-9) and assigns it to the board.
TEST Step 3: run the place marker function using test parameters and display the modified board
**Step 4: Write a function that takes in a board and checks to see if someone has won. **
TEST Step 4: run the win_check function against our test_board - it should return True
Step 5: Write a function that uses the random module to randomly decide which player goes first. You may want to lookup random.randint() Return a string of which player went first.
Step 6: Write a function that returns a boolean indicating whether a space on the board is freely available.
Step 7: Write a function that checks if the board is full and returns a boolean value. True if full, False otherwise.
**Step 8: Write a function that asks for a player's next position (as a number 1-9) and then uses the function from step 6 to check if its a free position. If it is, then return the position for later use. **
Step 9: Write a function that asks the player if they want to play again and returns a boolean True if they do want to play again.
Step 10: Here comes the hard part! Use while loops and the functions you've made to run the game!