Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using Python 3 Game: Minesweeper Import the turtle and cell modules 1. Write the registerShapes function (it must match the documentation in game.html) This function

Using Python 3

Game: Minesweeper

Import the turtle and cell modules

1. Write the registerShapes function (it must match the documentation in game.html)

This function registers the 12 icon shapes

2. Establish private attributes for the board size, board (a list), number of bombs, cells probed

Fill the board with Cell objects, making them the question icon and moving them to the proper position on the screen. (Cell objects understand Turtle methods.)

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

image text in transcribed

##CODES##

import game

import turtle

def main():

def play(x,y): #creates a closure function

turns,left = g.probe(x,y) #this gives a tuple

if left == 0: # if the number of bombs runs out in Minesweeper, it will restart the game

again = turtle.textinput('you took {} turns'.format(turns),'Play again?')

if again == 'y':#if the user type "y" to replay the game again

main()

elif again == 'n': # if the user type "n" to stop playing the game

turtle.bye() #this closes the screen or the game entirely

size = int(turtle.textinput('Minesweeper','board size')) #converts the method into an integer

g = game.Game(size)

done = False # creates a loop (boolean)

while not done:

mines = int(turtle.textinput('Minesweeper','How many mines?'))#ask how many mines

done = g.hideMines(mines) #hides the mines

turtle.onscreenclick(play) #uses the default mouse icon to click on the minesweeper #turtle.onscreenclick(g.probe) creates a different mouse

main()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Database Relational Model A Retrospective Review And Analysis

Authors: C. J. Date

1st Edition

0201612941, 978-0201612943

More Books

Students also viewed these Databases questions

Question

1 / 2 . 5 % 1 Q ) ftb 'J C

Answered: 1 week ago