NaNoGenMo / 2016

National Novel Generation Month, 2016 edition.
https://nanogenmo.github.io
162 stars 7 forks source link

An AI Plays RoyalClod (an invented board game!) #55

Open blackle opened 7 years ago

blackle commented 7 years ago

My project is going to be something along the lines of the book "Kasparov versus The World", wherein an AI describes their reasoning behind each move they make in a board game with a human. To generate the book the user must play this game with the AI.

The game will be an invented one, and I will train the AI to play it with an ensemble of machine learning methods, that it will learn to chose from. For example, if the AI chooses to make it's next move based on a decision tree, it will describe the most prominent rule in that tree that made it decide to make that move.

If I can figure out how to do it, I might make the AI try to hypothesize why the human makes them moves that it makes, and comment on it.

Development will appear here: https://github.com/blackle/NaNoGenMo-2016

ikarth commented 7 years ago

I like this idea on a number of levels. Looking forward to seeing what you come up with!

blackle commented 7 years ago

Day 1: Started implementing a simulator for the aforementioned game, which is still unnamed. I've had the idea for this game for a number of years, and I already wrote a simulator to ensure it's balanced and has some element of strategy. Unfortunately that simulator was deleted accidentally.

I haven't gotten around to writing up the rules, but as a sneak peak here's a diagram of the game board https://github.com/blackle/NaNoGenMo-2016/blob/master/Emulator/board_diagram.png

blackle commented 7 years ago

Day 2: I have decided on a name for the invented board game. I call it "Clod." I will probably write up the rules in english tomorrow.

Basically completed the emulator. Pits random players against each other and gathers statistics. There seems to be a first player advantage of about 51/49, which I think is acceptable.

See https://twitter.com/blacklemon67/status/794006488666828800 for some images of finished games. Anyone who can figure out the scoring mechanic before tomorrow wins 100 internet points :3

blackle commented 7 years ago

Day 3.1: I decided to do some stuff this morning. I implemented a rudimentary AI that evaluates moves based on the size of the territories it borders, and picks the biggest size (the word "territory" should give a big hint to how Clod is scored.) Against a random player it wins 95% of the time, which seems to imply that there is an element of strategy to this game, despite being very random.

I intend to type up the rules for Clod at lunch. This evening I'll probably refactor the code so it's cleaner and put in a plugin system for AI brains.

checkout https://github.com/blackle/NaNoGenMo-2016/tree/master/Emulator and build to see it collect statistics on 20000 games C:

blackle commented 7 years ago

Day 3.2: I have written up the rules for Clod! They can be read here: https://github.com/blackle/NaNoGenMo-2016/blob/master/Emulator/README.md

The game the AI will actually play is called RoyalClod, which is a souped up version with a larger playing board. The description for that version can be read at the bottom of that readme.

blackle commented 7 years ago

Day 3.3: I added some simple english text describing the AI's reasoning. As the AI gets more complex this text should grow.

some example output

I could probably already add more code to have the AI describe the second best decision, or comment on white's move, but I'd rather move toward the machine learning part of this project than feed in hard coded text.

superMDguy commented 7 years ago

Wow this is looking good. That's a cool game you oimnvrnted, and its amazing hold fast you got it this far.

blackle commented 7 years ago

Day 3.4: wrote an executable called "statistics" that spawns 8 threads to collect game stats in parallel. This will become useful tomorrow when I start putting together AI learning.

@superMDguy all I can say is hyperfocus is a powerful and scary thing, haha

blackle commented 7 years ago

Day 4: couldn't do much today since I had other plans, but I did fiddle around with the code I already had, and made the height and width preprocessor defines, and the code as a whole runs quicker now.

blackle commented 7 years ago

Day 5: same as yesterday, but I did put something in: made a dynamic plugin system for AI code

There's a class called "Brain" that takes the name of a plugin in it's constructor and exposes a function int chooseMove(MoveList& m), where the return value is the index of the move in that list. The actual function is loaded from a shared object library name.so (where name is what was passed)

Right now there is only one plugin, brainExample, that returns the number 420. lol

Tomorrow I'm planning on reorganizing the code and bringing in a more sophisticated build system other than make, and so I can have a "bin" directory I can put into my .gitignore file