Question: I need help with my poject for python: 'Win at Nim' Game Consider the game of Nim (https://en.wikipedia.org/wiki/Nim) We would like to create a program

I need help with my poject for python: I need help with my poject for python: 'Win at Nim' Game

'Win at Nim' Game Consider the game of Nim (https://en.wikipedia.org/wiki/Nim) We would like to create a program that is able to play 'Nim' against a human opponent and learn fronm each game. In order to keep this simple, we will be using the subtraction game variant where there is only one large pile of 20 items and players are restricted to only taking 1,2, or 3 items at a time. You could choose whether you want to implement a misre game or a normal game Implementation 1. Your program will need to be able to write what it learns to a file. It will also need to be able to open that file when the game is first executed to load that information. This file will have one line for each possible status of the pile (starting with 20 items and getting down to 1). On each of these lines you may have additional information but should definitely include six integer values. These values will be the number of games won after choosing a certain number of items and how many times each option has been chosen. For example, first line may look like 20 to represent that when the pile has 20 items in it choosing to take one item results in winning 3 out of 5 the times, taking two items results in winning 7 out of 10 times and taking three items results in winning 1 out of 4 times. 10 4 2. When playing the game, the computer will choose to take the number of corresponding items that matches the greatest chance of winning as long as at least one of those options is greater than 50% with at least three trials. If all options are less than or equal to 50% or each of the options has been tried less than three times the computer will choose randomly. If the winning chances of, let's say, option 1 and option 2 are same (and max), then computer will make a random choice from these two options 3. The computer will need to track what decisions it makes over the course of the game and update the values for wins and tries after each game ends. Some things that might help you with the implementation First, write the code for a simple 2-player 'nim' game, where the players take turns and the computer makes selection by picking a random number from 1,2, or 3 Then, write a function which updates the text file after each run of the game. Update how computer makes its choice according to point #2 of implementation. I hope it makes sense, that you will be playing this game a number of times before your computer actually starts learning from the data vou are building for it. * *

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!