Small train project: Finger addition battle

Project name: Small train project: Finger addition battle

Team members: Pieter Algera

Quick description: A game that is too complicated to explain in 1 or 2 lines but I would really like to make an AI for the game.

Goals:   -Create the game

-Create the AI

“Small train projects” are small projects that I create while taking the train as I commute to work or school. They are normally small enough to be written in 2-3 hours.

I was in the subway on the way home last week and 2 kids sitting across from me were playing a game. I started watching them to try and figure out what they were doing. The game is quite simple. The rules, as I have figured them out, is as follows. Each player starts with both hands. Each hand has 1 finger extended. Each in his own turn, picks one of his own hands and then touches another hand. The other hand then adds the amount of fingers from the attacking hand to his hand. He will now have a hand with 1 finger and one with 2 fingers. The game carries on like that until a hand reaches 5 or “More” fingers. When a hand is full, it is pulled from the game. The first player to eliminate both hands of his enemy wins. Another rule I saw later was that when a hand is dead and the other hand has more than 1 finger. The hand can be split up and half of the one hand can be given to the dead hand.

For this project I decided to make it in C# for its easy access to the console. I wanted to make the game using the console so that I don’t have to worry about creating an intricate UI. I started by making the base game with 2 human players. The AI will come later. I create a hand class to hold the basic finger data and some basic functions needed for the hand. I then create a player class that will hold both hands and will also do the control part of the game. I then create a GameLoop class that will hold all the game logic of the program. Start up the players, tell them what to do, organise the states, etc.
When the base game part is done, I go on to try and make the AI for the game. I didn’t have enough train time to finish it after 2h so I finished it the next morning. I finished the AI not too long after leaving. It is a very simple AI. All it does is randomly choose what to do. No logic to its choices. Doing that kind of AI would take a while and I think I will leave that for the next Small Train Project. I thought of maybe trying to do a neural network kind of thing! But I am getting ahead of myself.
With the AI working, I make the game a little better. I add states to go from a MainMenu to the game itself to a gameover state and finally to the end game state. All of this makes the game feel like it is complete.

A little run through of the game!

This slideshow requires JavaScript.

I am very happy at what I got right in the end. There is a lot of stuff that I would like to add to make it better.
-I want to make a real AI using something like Neural networks or a genetic algorithm. I want it to really be able to make an educated choice about what to do next.
-I want to port the game over to Unity. While I was programming the game, I was keeping in mind the fact that I could one day move it to Unity.
-I would also like to integrate the leap motion controller into the game. It would be perfect for this game.

So I have quite a few ideas that I can explore if ever I feel like it. Which I just might do.

I hope you enjoyed the article. If you liked it, please give it a like and share it. If you want more then by all means subscribe to the blog. Thank you for reading.

Leave a comment