0

I would want to know how to code the game Nim

This is a game for two players. You will need 16 objects, like matchsticks or counters. There are a total of 16 sticks. Set the objects out in a row of 7, a row of 5, a row of 3 and a row of just 1. Players take turns in a choosing a row then removing any number of objects from that row. The player left with the last object is the loser.

3rd Apr 2024, 3:21 PM
Vinki
2 Réponses
+ 2
Outside of the web playground, you could write this game in Python or C++ or Java in a way, that each players' moves are chosen by the computer, following a certain predefined strategy. This way the game can run instantly to completion, fully automatically. But actually this is more of a simulation then. :)
3rd Apr 2024, 4:52 PM
Tibor Santa
Tibor Santa - avatar
+ 1
Vinki , The only program type that supports interactivity in the Sololearn Code Playground is "Web" (HTML, CSS, JS). For all the others, including Python, the user is required to enter all inputs before the program runs. But since it's for two players, I don't think you can even do it in Web, unless it's designed for two players sitting next to each other and handing a phone back and forth, or if one of the "players" is actually the program itself (like one player versus the computer). To make a game that two phones would each run a copy of that would communicate with each other over the internet is too involved. You'd need to build it in an actual IDE.
3rd Apr 2024, 3:58 PM
Rain
Rain - avatar