13 NIM with unbeatable AI

PrinceOfCreation's picture
Build image: 
In-game name (NO VISITORS! Must be LEARNER rank or higher!): 
PrinceOfCreation
Builder name(s) and current ranks: 
PrinceOfCreation: Learner
Creation location: 
775 87 -175
Machine Features: 
This is 13 NIM with unbeatable AI. At the heart of the machine, there is a comparator signal strength lock. This depicts the number of lights, or "counters" are on, or "left". The comparator lock subtracts one by sending a 3 tick pulse of 1 signal strength into one of the locking comparators on subtract mode. This is fine for picking 1, but, for example, picking 3 has to repeat the previous execution twice more. I use a furnace with one item in it, and then a comparator 1 block away. A piston then sets a block in between the furnace and said comparator, and 3 ticks later removes. As comparators can read through blocks, this is a nice way of momentarily putting a pulse of controlled signal strength though the machine. This NIM has built-n turn detection, which means it is also almost 100% spam proof. The way it manages whether the player can go or not is just some very basic AND gates with their second inputs tied together and tied to the output of turn detect. Note: the turn detect is just a dropper RS-NOR latch. It doesn't need to be, but I find two droppers facing into each other a lot more compact than a T-flip-flop. Another feature: it uses only two pistons. My NIM doesn't have win detect, but I don't think it needs to as the AI will always win. Finally, there is also a reset button. This feeds a 13 signal strength into the comparator signal strength lock, (there are 13 lights or "counters") and also makes sure it is the player's go. Speaking of AI, this machine's AI is very fast. This is mainly because it is very simple. It takes its go after the player, from 3 lines from the pick 1 pick 2 pick 3 selector board. It then merely finds the inverse of the data, and feeds that into its own pick 1 pick 2 pick 3 board, i.e. if the player picks 1 the machine will pick 3, if the player picks 2 the machine picks 2 and so on. This means that after a player go and machine go, there is always 4 picked. (3 and 1, 2 and 2 and 1 and 3). Because 13 mod 4 is 1, there will be 1 left after the final player-AI go, and in my version whoever takes the last counter will lose. AI always wins! Extra note: the machine will not break if there is, for example, one counter left and you pick 3. There is no negative NIM counters.
How To Use: 
Please press the reset button (only at the start) and then take your go - pick 1, pick 2 or pick 3. Your choice will be confirmed by the corresponding redstone lamp, or light, above the button you pressed. The turn light at the top of the game will indicate if you can play or not. After your go, the AI will make its go, again with the same options as you. The turn light will then go from AI's turn to your turn, indicating you can play again. Play continues until there is only one light left, which means the machine has won (you have to pick that last one). Technically, as described at the end of Machine Features, play could continue, but the amount of counters will simply remain at 0 until you reset. You can then play again.
Request status: 
Not approved

Comments

Farex's picture

This version of Nim seems to be one that is commonly created, but it is not the traditional Nim game, which is what we are looking for. In the traditional version of Nim, there are multiple rows, and on your turn you can take however many "pieces" from a row as you want, but only from a single row. You must always make a move, and once you have taken one from a row, you cannot take from another row until your next turn. The goal of the game is the same, make the opponent take the last piece. Here is an example of the traditional version of Nim, with the traditional layout: https://www.archimedes-lab.org/game_nim/play_nim_game.html

Note that, even for the traditional version, AI isn't very hard/complex, so you will probably have to do pretty good to get Regular for it. There is info about how to always win somewhere on the website I linked to above, but I could not say where specifically. It may be more in your interests to choose a different challenge, though.

Best regards,
~ Farex

By Farex