Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In Python language Consider a 2-player game where the board consists of two rows of 6 bins and a large scoring bin on each side.
In Python language
Consider a 2-player game where the board consists of two rows of 6 bins and a large scoring bin on each side. At the beginning of the game, the scoring bins are empty and the 12 smaller bins each have 3 small stones: Scoring 3 33333 Scoring bin 3 3 3 33 3 bin Each player selects a row of bins and a scoring bin according to the colorization above Specifically, the player sitting at the bottom of the board controls the bottom row of bins and attempts to accumulate stones in the scoring bin to his/her right. Similarly, the player sitting at the top of the board controls the top row of bins and attempts to accumulate stones in the bin to his/her right (i.e., the left bin as drawn on the page) Plav proceeds as follows 1. One player selects one of their six bins and removes all of the stones in it. The stones are deposited counter-clockwise, one per bin (including scoring bins), until all of the stones a. If the last stone is deposited in the player's scoring bin, he/she gets a second turn. b. If the last stone is deposited in an empty bin (other than a scoring bin) and the bin have been moved (However, you can't do this twice in a row; you can't have three straight turns.) across from it is not empty, then the player collects both the last stone dropped and all of the stones across from it 2. 3. Play then passes to the other player. Play concludes once all of the stones have been moved to the scoring bins. The player with more stones is declared the winner Implement this game in a Python script using techniques that we have covered so far in the class. Be sure to abide by the specific guidelines provided below. Example of rule la: The bottom player starts by selecting the 4th bin from the left side, so the board goes from this: To this: 1 3 33 0 4 4 He/she gets another turn because the last stone was dropped in his/her scoring bin. Example of rule 1b Suppose it is the top plaver's turn and the board looks like this: 1 1 3 01 2 6 5 If he/she selects the far right bin, the board looks like this once the stones have been moved 5 61 1 4 0 1 3 01 2 6 Consider the shaded pair of bins: the last stone was deposited in a bin that was empty, and there is at least one stone in the bin across from it. Thus all of the highlighted stones are captured, and the board looks like this: 5 60 1 4 0 3 0 0 2 6 5 Specific guidelines: .At the beginning of every turn, your program should neatly print out the board in its current state (use string format methods!). It should look something like this: 3 3 3 . Your program should use the input() function to prompt players to enter a number from 1-6 #1 corresponds to the leftmost bin as drawn on the screen, while #6 corresponds to the rightmost bin. When the game ends, output a line declaring the winner Make sure your program is neatly commented so it is easy to decipher your work. . Hints & Suggestions: The bins in the board can be represented by positions in a Python list. If the list indices correspond to bi 1. like this: 13 12 11 10 9 8 1 2 3 4 5 6 7 Then you can set up your initial board like so inner row[31*6 board-[e] + inner_row [0]+inner_row For example, board[0] would correspond to the left scoring bin and board [8] would correspond to the top player's bin #6 2. For rule 1b, you can see that board [1] is matched with board [13], board [2] is matched with board[12], etc. To compare these in your script you can create an object artner and then use it to pull a value from board, like so: partner-[0,13,12,11,10,9,8,0,6,5,4,3,2,1] board [partner[21] # this will return board [12] 3. Most of the script can be wrapped into a while loop. What must be true to break out of the loop? Break down the assignment into smaller pieces. Start with displaying the board, then add switching between the players, etc. Add in rules la and 1b once everything else is working 4. Consider a 2-player game where the board consists of two rows of 6 bins and a large scoring bin on each side. At the beginning of the game, the scoring bins are empty and the 12 smaller bins each have 3 small stones: Scoring 3 33333 Scoring bin 3 3 3 33 3 bin Each player selects a row of bins and a scoring bin according to the colorization above Specifically, the player sitting at the bottom of the board controls the bottom row of bins and attempts to accumulate stones in the scoring bin to his/her right. Similarly, the player sitting at the top of the board controls the top row of bins and attempts to accumulate stones in the bin to his/her right (i.e., the left bin as drawn on the page) Plav proceeds as follows 1. One player selects one of their six bins and removes all of the stones in it. The stones are deposited counter-clockwise, one per bin (including scoring bins), until all of the stones a. If the last stone is deposited in the player's scoring bin, he/she gets a second turn. b. If the last stone is deposited in an empty bin (other than a scoring bin) and the bin have been moved (However, you can't do this twice in a row; you can't have three straight turns.) across from it is not empty, then the player collects both the last stone dropped and all of the stones across from it 2. 3. Play then passes to the other player. Play concludes once all of the stones have been moved to the scoring bins. The player with more stones is declared the winner Implement this game in a Python script using techniques that we have covered so far in the class. Be sure to abide by the specific guidelines provided below. Example of rule la: The bottom player starts by selecting the 4th bin from the left side, so the board goes from this: To this: 1 3 33 0 4 4 He/she gets another turn because the last stone was dropped in his/her scoring bin. Example of rule 1b Suppose it is the top plaver's turn and the board looks like this: 1 1 3 01 2 6 5 If he/she selects the far right bin, the board looks like this once the stones have been moved 5 61 1 4 0 1 3 01 2 6 Consider the shaded pair of bins: the last stone was deposited in a bin that was empty, and there is at least one stone in the bin across from it. Thus all of the highlighted stones are captured, and the board looks like this: 5 60 1 4 0 3 0 0 2 6 5 Specific guidelines: .At the beginning of every turn, your program should neatly print out the board in its current state (use string format methods!). It should look something like this: 3 3 3 . Your program should use the input() function to prompt players to enter a number from 1-6 #1 corresponds to the leftmost bin as drawn on the screen, while #6 corresponds to the rightmost bin. When the game ends, output a line declaring the winner Make sure your program is neatly commented so it is easy to decipher your work. . Hints & Suggestions: The bins in the board can be represented by positions in a Python list. If the list indices correspond to bi 1. like this: 13 12 11 10 9 8 1 2 3 4 5 6 7 Then you can set up your initial board like so inner row[31*6 board-[e] + inner_row [0]+inner_row For example, board[0] would correspond to the left scoring bin and board [8] would correspond to the top player's bin #6 2. For rule 1b, you can see that board [1] is matched with board [13], board [2] is matched with board[12], etc. To compare these in your script you can create an object artner and then use it to pull a value from board, like so: partner-[0,13,12,11,10,9,8,0,6,5,4,3,2,1] board [partner[21] # this will return board [12] 3. Most of the script can be wrapped into a while loop. What must be true to break out of the loop? Break down the assignment into smaller pieces. Start with displaying the board, then add switching between the players, etc. Add in rules la and 1b once everything else is working 4Step 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