Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Page of 2 ZOOM import random import os . path import json random.seed ( ) def draw _ board ( board ) : # develop
Page of ZOOM import random import ospath import json random.seed def drawboardboard: # develop code to draw the board pass def welcomeboard: # prints the welcome message # display the board by calling drawboardboard pass def initialiseboardboard: # develop code to set all elements of the board to one space return board def getplayermoveboard: # develop code to ask the user for the cell to put the X in # and return row and col return row, col def choosecomputermoveboard: # develop code to let the computer chose a cell to put a nought in # and return row and col return row, col def checkforwinboard mark: # develop code to check if either the player or the computer has won # return True if someone won, False otherwise return False def checkfordrawboard: # develop cope to check if all cells are occupied # return True if it is False otherwise return True def playgameboard: # develop code to play the game # star with a call to the initialiseboardboard function to set # the board cells to all single spaces # then draw the board # then in a loop, get the player move, update and draw the board # check if the player has won by calling checkforwinboard mark # if so return for the score # if not check for a draw by calling checkfordrawboard # if drawn, return for the score # if not, then call choosecomputermoveboard # to choose a move for the computer # update and draw the board # check if the computer has won by calling checkforwinboard mark # if so return for the score # if not check for a draw by calling checkfordrawboard # if drawn, return for the score #repeat the loop return def menu: # get user input of either or q # Play the game # Save score in file 'leaderboard.txt # Load and display the scores from the 'leaderboard.txt # q End the program return choice def loadscores: # develop code to load the leaderboard scores # from the file 'leaderboard.txt # return the scores in a Python dictionary # with the player names as key and the scores as values # return the dictionary in leaders return leaders def savescorescore: # develop code to ask the player for their name # and then save the current score to the file 'leaderboard.txt return def displayleaderboardleaders: # develop code to display the leaderboard scores # passed in the Python dictionary parameter leader pass
Page
of
ZOOM
import random
import ospath
import json
random.seed
def drawboardboard:
# develop code to draw the board
pass
def welcomeboard:
# prints the welcome message
# display the board by calling drawboardboard
pass
def initialiseboardboard:
# develop code to set all elements of the board to one space
return board
def getplayermoveboard:
# develop code to ask the user for the cell to put the X in
# and return row and col
return row, col
def choosecomputermoveboard:
# develop code to let the computer chose a cell to put a nought in
# and return row and col
return row, col
def checkforwinboard mark:
# develop code to check if either the player or the computer has won
# return True if someone won, False otherwise
return False
def checkfordrawboard:
# develop cope to check if all cells are occupied
# return True if it is False otherwise
return True
def playgameboard:
# develop code to play the game
# star with a call to the initialiseboardboard function to set
# the board cells to all single spaces
# then draw the board
# then in a loop, get the player move, update and draw the board
# check if the player has won by calling checkforwinboard mark
# if so return for the score
# if not check for a draw by calling checkfordrawboard
# if drawn, return for the score
# if not, then call choosecomputermoveboard
# to choose a move for the computer
# update and draw the board
# check if the computer has won by calling checkforwinboard mark
# if so return for the score
# if not check for a draw by calling checkfordrawboard
# if drawn, return for the score
#repeat the loop
return
def menu:
# get user input of either or q
# Play the game
# Save score in file 'leaderboard.txt
# Load and display the scores from the 'leaderboard.txt
# q End the program
return choice
def loadscores:
# develop code to load the leaderboard scores
# from the file 'leaderboard.txt
# return the scores in a Python dictionary
# with the player names as key and the scores as values
# return the dictionary in leaders
return leaders
def savescorescore:
# develop code to ask the player for their name
# and then save the current score to the file 'leaderboard.txt
return
def displayleaderboardleaders:
# develop code to display the leaderboard scores
# passed in the Python dictionary parameter leader
pass
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started