write a python program Problem Description You will write a program that impleme
ID: 3677030 • Letter: W
Question
write a python program
Problem Description You will write a program that implements a two-player game called A Drop in the Bucket. There are five buckets in a row. Every bucket contains a marble. On every move a player can select one of the buckets (except the rightmost bucket) and move all the marbles in the bucket to the neighboring bucket to the right. They player who cannot make a move (because all the marbles are in the rightmost bucket) loses the game. Play begins with one marble in each bucket: On each turn the prompt pops up a prompt window whose title bar contains either "Player 1's Turn" or Player 2's Turn", as appropriate, with a sensible prompt that asks the user to select a bucket (1, 2, 3 or 4). For example: Player 1's TurnX Which bucket do you select? OK Cancel On his/her turn a player must choose a bucket containing a marble (or marbles), other than the rightmost. For example, suppose on Player 1's first turn he/she chooses bucket 3. The buckets update to this configuration:Explanation / Answer
# ///////////// part of the python code for A Drop in Bucket Game //////////
# call the functions in Blackboard from this code
def mainCode():
turn #player1 or player 2
numberOfMarblesInBucket1
numberOfMarblesInBucket2
numberOfMarblesInBucket3
numberOfMarblesInBucket4
numberOfMarblesInBucket5
def drawBucketsInInitialLocations():
nameOfTurtle = Bob
# let the total screen co ordinates be 0,0 to 900, 500
x = 100
y = 50
numOfMarbles = 1
# initially draw one marble in each bucket
drawBucket(nameOfTurtle,
# we will first draw all 5 buckets - each bucket is of width 20 pixels or what ever height mentioned in the function drawBucket in Blackboard
# we need not worry about height as the draw marble draws a marble of much smaller height than the bucket height
# leave a gap of 10 pixels between each bucket
# then draw 1 marble in each bucket
# the bucket 1 spans from 100,50 to 120, 50
# the bucket 2 spans from 130,50 to 150, 50
# the bucket 3 spans from 160,50 to 180, 50
# the bucket 4 spans from 190,50 to 210, 50
# the bucket 5 spans from 210,50 to 230, 50
# ///////////// part of the python code for A Drop in Bucket Game //////////
# call the functions in Blackboard from this code
def mainCode():
turn #player1 or player 2
numberOfMarblesInBucket1 = 1
numberOfMarblesInBucket2 = 1
numberOfMarblesInBucket3 = 1
numberOfMarblesInBucket4 = 1
numberOfMarblesInBucket5 = 1
def drawBucketsInInitialLocations():
nameOfTurtle = Bob
# let the total screen co ordinates be 0,0 to 900, 500
x = 100
y = 50
numOfMarbles = 1
# initially draw one marble in each bucket
drawBucket(nameOfTurtle,
# we will first draw all 5 buckets - each bucket is of width 20 pixels or what ever height mentioned in the function drawBucket in Blackboard
# we need not worry about height as the draw marble draws a marble of much smaller height than the bucket height
# leave a gap of 10 pixels between each bucket
# then draw 1 marble in each bucket
# the bucket 1 spans from 100,50 to 120, 50
# the bucket 2 spans from 130,50 to 150, 50
# the bucket 3 spans from 160,50 to 180, 50
# the bucket 4 spans from 190,50 to 210, 50
# the bucket 5 spans from 210,50 to 230, 50
def countBallsInBucket(bucketNumber):
# this will count and print the number of balls in each bucket
print(numberOfMarblesInBucket1)
print(numberOfMarblesInBucket2)
print(numberOfMarblesInBucket3)
print(numberOfMarblesInBucket4)
print(numberOfMarblesInBucket5)
def moveBall(fromBucket, toBucket)
# no need to store the number of balls as the player moves all the balls
if fromBucket == 1:
numberOfMarblesInBucket1 = 0
if fromBucket == 2:
numberOfMarblesInBucket2 = 0
if fromBucket == 3:
numberOfMarblesInBucket3 = 0
if fromBucket == 4:
numberOfMarblesInBucket4 = 0
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.