K
King Kong
wondering does anyone know how to help with this problem
n and t should be constants in your program, but give them better names
like INITIAL_NUM_MATCHES and MAX_ALLOWED_TO_TAKE. You may assume that
the user plays first and the computer second, and so on.
When n=k*(t+1)+1, for some constant k, your program should always win.
When this is not the case, your program should take a random number of
matches from the pile. If the user makes an error on their turn, your
program should play correctly and win the game.
Your program should have a class called Nim that manages the game
itself. Your main program can manage user input, or you can put this
into another class if you wish.
A good approach to this assignment is to assume that the initial number
of matches is 21 (n=21) and that the maximum number of matches that may
be taken on a turn is 4 (t=4). When you have this problem solved and you
are satisfied your program is correct, extend your program to handle the
more general case where n and t can have other values.
n and t should be constants in your program, but give them better names
like INITIAL_NUM_MATCHES and MAX_ALLOWED_TO_TAKE. You may assume that
the user plays first and the computer second, and so on.
When n=k*(t+1)+1, for some constant k, your program should always win.
When this is not the case, your program should take a random number of
matches from the pile. If the user makes an error on their turn, your
program should play correctly and win the game.
Your program should have a class called Nim that manages the game
itself. Your main program can manage user input, or you can put this
into another class if you wish.
A good approach to this assignment is to assume that the initial number
of matches is 21 (n=21) and that the maximum number of matches that may
be taken on a turn is 4 (t=4). When you have this problem solved and you
are satisfied your program is correct, extend your program to handle the
more general case where n and t can have other values.