Introducing Nim.ai

AI that plays Nim!

Welcome to Nim.ai where an artificial intelligence system, named Nimma, trains itself through reinforcement learning, by playing against itself repeatedly and learning from experience, eventually the system will learn which actions to take and which actions to avoid.

For those who don't know about Nim, the game begins with some number of piles, each with some number of objects. Players take turns: on a player’s turn, the player removes any non-negative number of objects from any one non-empty pile. Whoever removes the last object loses.

Nimma uses the Q-Learning algorithm to create reward system for the learning process. An action that loses the game will have a reward of -1, an action that results in the other player losing the game will have a reward of 1, and an action that results in the game continuing has an immediate reward of 0, but will also have some future reward.

With these rules in mind, Nimma goes through a training period of 10,000 games where it keeps playing the game with itself and rewards and punishes itself, given a situation.

I hope you enjoy the demo!

Inspiration behind Nimma

Nimma.ai was a little project that was inspired after learning about artificial intelligence. The game of Nim was one I used to play as a child with my older siblings, and I thought it would cool to implement my childhood game and play it against an AI.

Lessons learned from the project

Nimma had taught the various aspects of reinforcement learning and how Q-Learning is an amazing concept for AI systems. The thought of devising a way to make a rewarding system to teach an AI as if it were a child, was an eye-opener to me.

There are a lot of concepts for reinforcement learning which I had researched about after this project (about Markov Decision Process and all that good stuff) which brought me closer to learning about AI algorithms and systems, mmore enjoyable.