Question: needing help creating contructor for NIM game in pythonThe Constructor The constructor method is named _ _ init _ ( ) . This method is

needing help creating contructor for NIM game in pythonThe Constructor
The constructor method is named__init_(). This method is called whenever a new instance of the class is
created and is responsible for initializing the attributes of the instance. The header for the constructor for the
Nim class looks like this:
def__init_(self, piles, stones, limit, is_copy=False):
A description of each of the parameters for _() is provided below.
self - This refers to the instance being created.
piles - This should be an integer indicating the number of piles to be used.
stones - This should be an integer indicating the number of stones per pile.
limit - This should be an integer that indicates the maximum number of stones that can be taken in a
single move.
The constructor should perform the following task:
Create attributes self.piles, self.stones, and self.limit, setting each one equal to the
corresponding parameter.
Create an attribute named self.winner, setting it equal to None.
Create an attribute named self.turns, setting it equal to 0.
Create an attribute named self.cur_player, setting it equal to 1.
Create an attribute named self . board, setting it equal to a list whose length is equal to piles, and with
each entry containing the value stones. For example, if we were to create a Nim instance using
Nim(piles=4, stones=7, limit=3), then self.board should equal 7,7,7,7.
The constructor does not need to return anything.
 needing help creating contructor for NIM game in pythonThe Constructor The

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!