代写接单-ST117 Introduction to Statistical Modelling (2023) • WR-B: Building Nim Please read guidance on expected answer format on Moodle in Log-4 week

欢迎使用51辅导,51作业君孵化低价透明的学长辅导平台,服务保持优质,平均费用压低50%以上! 51fudao.top

ST117 Introduction to Statistical Modelling (2023) • WR-B: Building Nim Please read guidance on expected answer format on Moodle in Log-4 week

All versions of Nim used in the following tasks are explained in the table on page 2.

1. Build basic Nim

Code up a stable human-against-human Nim, normal play, platform in R. You need to include functionalities for the two humans to input their choices regarding the size of the initial three piles, and their game moves. On the output side you need visualisations of the current state of the piles, errors messages addressing invalid input, and, at the end, a line declaring who won. (Also, store the data about the full course of the game as that will be needed in 3.)

Hints:

• Simplify: formulate the core task to implement the idea of Nim without any bells and whistles (e.g. just one pile with a fixed number of counters and a cap on the number of counters that can be removed in a step).

• Modularise: break the task down into more manageable steps.

• Make a sketch of the different elements required for the most basic implementation. As appro-

priate, you can later add extensions in a different colour.

• Initially, keep the input/output very simple.

• Do not forget to make your code stable against nonsensical data input. For example, if players

choose negative integers or fractions, the game should not crash but remind them of the rules

and ask for a new input.

• A very simple way of showing the current states of the piles is plotting three lines with the

relevant number a characters, e.g. the state “8 counters in row 1, 3 counters in row 2, 1 counter in row 3” can be visualised as follows:

          ********

          ***

          *

2. Play Nim

Have each pair of students in your Report Pod play two games of Nim. (If you are in different locations, improvise with using via electronic devices to communicate your moves when playing against each other.) Report the results in an R or LaTeX table or with pencil & paper records.

3. Visualise the course of the game

Design and implement a visual representation that shows a full record of the timeline of all the moves played by each of the players. Explain the rationales for your choices (symbols, colours, layout etc.). Note: full credit will be awarded for implementations that correctly visualise the full course of the game, even without achieving high artistic standards.

4. Extensions of Nim

Generalise your implementation: allow any number of piles (up to a manageable upper limit) and include the mis`ere play option.

5. Artificial intelligence

Create a human-against-computer version of the game by coding up a strategy to replace one of the players. In the first instance, this artificial intelligence agent could be rather naive, e.g. play moves sampled at random (as long as compatible with the rules of the game). Then let the artificial intelligence agent consider winning positions or further aspects of winning strategies. Explain your implemented strategy.

Note: full credit will be awarded for creating any at least very partially intelligent agent handling basic Nim.

6. Build Lasker Nim

Implement Lasker Nim following our formalised description listed in the table below.

Note: full credit can be obtained for a version of Nim, normal play, without any further extensions.

 

  Rules of Nim

  Version

 Description

 Source/context

   Nim, normal play (original description)

 “The game is played by two players, A and B. Upon a table are placed three piles of objects of any kind, let us say counters. The number in each pile is quite arbitrary, except that it is well to agree that no two piles shall be equal at the beginning. A play is made as follows: —The player selects one of the piles, and from it takes as many counters as he chooses; one, two, . . ., or the whole pile. The only essential things about a play are that the counters shall be taken from a single pile, and that at least one shall be taken The players play alternately, and the player who takes up the last counter or counters from the table wins.”

   CL Bouton, Nim,

A Game with a Com- plete Mathematical Theory, Annals of Mathematics,

2nd Series, Volume 3, No. 1/4 (1901-1902), pp.35-39

 Nim, mis`ere play

 The player who takes the last counter(s) looses.

 Most common version

   Lasker Nim

 The standard version of Nim, but with an additional op- tion during the turn for the player to “split” a chosen pile into two smaller non-empty piles. This splitting does not remove any counters from the pile, and since the split piles are required to be non-empty, we require a minimum of at least 2 counters in the pile for it to be split. The player who made the split will also be able to decide how many counters to allocate to each of the smaller piles.

   Our formalised descrip- tion

   Lasker Nim (original description)

 “There is a variant of Nim in which a move consists in either removing stones from a pile or dividing a pile of at least two stones into two piles, not necessarily of equal size. The player who removes the last stone wins. Is there a simple analysis for this game as there was for Nim?”

   “Lasker Nim: Winning along a Secret Path” in newline J Bewersdorff, Luck, logic, and white lies: The mathematics of games, CRC Press, 2021

     2

 

 

51作业君

Email:51zuoyejun

@gmail.com

添加客服微信: abby12468