GANN-EWN / Part 1 / GANNs (Genetic Algorithms applied to Neural Networks)

Combining Genetic Algorithms and Neural Networks is an idea that has been troubling my mind for the last 20 years. Unfortunately, life went in the way and I didn’t have a real chance of putting this idea into practice. Neural networks are very often used to do some “classifying” jobs, and they are very good at it. At least they got far beyond what we humans could program ourselves. However, as I have ideas for developing very interesting games, I also had in mind to have an AI play those games, and an AI that would actually learn how to play them, rather than programing it myself. This is exactly what the guys at DeepMind have been doing in the recent years. From Atari games to Go and Chess (and Shogi), they have amazed us all.

As I’m going back to my original interest in AI, I have taken upon myself to build an AI from scratch that would do exactly what I had in mind 20 years ago: learn how to play games.

In the meantime, things in the AI field have evolved. Graphics cards have opened new horizons for training bigger and faster Neural Networks. I have had some graphics cards that I used at some point to mine some cryptocurrencies for fun. Those cards were AMD cards, and they were getting hot very easily (the 7970 was going up to 100 degrees Celsius, I suspect that the fitting of the radiators were poorly made). I set up a watercooling system for the whole miner. Although it was a very interesting experience, it came to an end rather quickly. since ASICs kicked in and rendered graphics cards useless.

At the time, I started a project for handwriting character recognition (more on this project later…), and I used one of those cards to apply some graphics transformations (Hough transform and such). But they also consume a lot of electricity. So, sorry AMD, but I switched to Nvidia (I don’t own any stocks of either of those companies… or any other company, by the way, but I do believe that AMD is seriously losing ground here), which also has some great support with tools to build Neural Networks like TensorFlow.

So I wanted to start with a simple game and a simple goal:

  • create a neural network framework from scratch, with NNs as generic as possible, including non linear functions, spikes, max and many operations, the ones that will be best will be selected by the genetic algorithm,
  • a genetic algorithm to make those NNs evolve,
  • all this should be able to run both on CPUs and GPUs (at least the most power-consuming parts), and I originally planed to learn some Cuda although I had prior OpenCl experience.

But everything had to start somewhere. And I didn’t want to tackle Chess or Go as my first GANN project. Anyway, the DeepMind guys have done that already!

So I had to aim for something simple for a start, and at the same time some game that I didn’t know well so that I wouldn’t be tempted to direct the algorithm and make “Stockfish for game XXX”.  On the same note, another strong criteria was also that it shouldn’t be a game that had been solved by mainstream software, like Chess, Checkers or Reversi/Othello. At the website littlegolem on which I play board games, there are some games that I don’t know well (yet) and also many games for which mainstream software is not really available. One of them is called “Einstein Würfelt Nicht” (which I will call EWN in the future) and is actually a dice game, played on a 5×5 board. When I started this project, I had never played that game but the rules seemed quite simple and I decided to have a go at it. This was of course the first attempt, the first prototype, basically some starting point, but certainly not the end point.

There are also two variants of the game on the site, which would be also nice to tackle. My initial goal there was to defeat human players and become a top player on the site. Note that this particular site is also very flexible with its players, and doesn’t ban anyone. If you don’t like playing against cheaters or robots, then that site is definitely not for you. But personally I learn a lot by playing with any kind of opponent, it doesn’t matter if I win or if I lose.

I will develop that story in the next articles, and I will also post some of the code soon on my gitlab account. However, I will not post the full code, don’t expect to be able to have a running bot that would play for you at EWN from there. But the generic code will be there and will be adaptable to other games as well.

The next part is here.

Introduction to this blog and who I am

Welcome to my blog!

To understand where this blog will be going, you have to get to know me first. Let me introduce myself briefly. I’m a poly-faceted and multi-interest person.

Here is a short list of my top interests:

  • Science in general. I have a variety of interests in Science and Technology, including Astronomy, Geology, Climatology, Nanotechnologies, 3D printing, and many others.  Along with the philosophical aspects that come with science, which are getting trickier every day (AI – Singularity, anyone? Trans Humanism, Genetic Tampering etc.).
  • Computer Science in particular. I’m a Computer Engineer, so Computer Science is definitely on my top list. As a child, I was always attracted to computers and especially how they can be programmed to do an endless number of things. My main area of interest, though, is Artificial Intelligence. I made a PhD in the 1990’s in that domain, and I’ve always kept myself up-to-date since then. In the recent years, we’ve seen quite a number of breakthroughs in that area. So for sure, this blog will contain a lot of articles about technology. One other area of interest is storage of data and how to keep it safe, which is a topic most people disregard too often until some irreparable damage happens. Not only should your data be safe, but also kept private. On this topic, I have been introduced to Cryptography at an early age by my father, who was giving me coded messages to decipher, so I know the technology and its thrilling history.
  • Libre Money. Blockchain technology can free us from the limitations and flaws of the current banking system. Not with Bitcoin or many other cryptocurrencies, but with a unique type of currencies called “Libre Currencies”. In fact, one such currency already exists, it is called Ğ1 and is powered by Duniter. I’m participating in the effort to translate some of the material there, including the Relative Theory of Money, which is the underlying theory for Libre Currencies. I have also written a program to help animators of the game Ğeconomicus (which is a good introduction to Libre Money).
  • Board Games. I have been playing Chess since age 5, and I’m a big fan of board games. The main point here is to never keep the brain still, and always learn from playing. I know a large variety of games, from Shogi to Checkers and from Go to Hex. You can see me regularly at littlegolem and I sometimes play Arimaa as well. I used to play RPG games (and was leading big teams in some) but I’m past that now. 🙂
  • Foreign Languages. I’m French and I’ve been in a bilingual school at an early age. I speak French (obviously), English (obviously again!), Spanish and German quite good, and I’ve studied a number of other languages to various degrees. These include Japanese, Italian, Portuguese, Esperanto, Russian, Turkish, Danish, Arabic, Chinese, and some Irish, which I find the most difficult of all. You can find me on duolingo. I’ve started an effort to help English speakers to learn French.
  • Cultures and Geography. Learning other languages is opening doors to other cultures. So I love to learn about different cultures all around the world.
  • History. Knowing a culture (including the one that came to me at birth) needs some knowledge about history. I love to learn about the history of the world.
  • Genealogy. Knowing your history comes with the search for your roots. I have worked on my genealogy tree, it goes back to the 18th century in many branches, and one branch goes as far as the 15th century.
  • Music. Cultures and history are filled with music. I love music, especially classical European music, but also folk music from all over the world, Ireland and Scotland, Flamenco (¡Olé!), Indian Ragas, South American music, Chinese Traditional (Guzheng and Ehru), and many more. As an amateur pianist I play mostly music from the Classical and Romantic eras but as a harpsichordist I focus on Baroque music. I do have recordings on the Internet, ask me where to find them! I’ve also recently started composing. I also know how to play a number of other instruments but I don’t practice much.
  • Movies. My wife and I watch a lot of movies. We don’t watch TV, but we do sometimes watch a couple of selected TV series. It’s always interesting to see how stories are designed.
  • Reading. Of course, I also read books, both fiction and non-fiction. I’ll probably post here some summaries of my readings along with my impressions.
  • This leads to a long lasting passion: writing. Actually I don’t understand why I didn’t start this blog earlier. I have written several (unpublished) novels during my teenage years and more in my 20’s, which I’m currently publishing on Wattpad (under a pen name). I have gone back recently to writing and am a published author (also under a pen name).
  • Rubik’s Cube. I have a strange history with this thing. 🙂 I’ll write about it later.
  • Psychology. I’m not a psychologist, but I’ve been learning a lot about it from my wife. It’s a fascinating subject.
  • Health. I’m definitely not a doctor, but I also gained quite some knowledge from my wife in that area.  Pesticides and GMOs vs Permaculture is something I know quite a lot about, even though I can’t call myself a specialist. I have a feeling that these subjects will be at the heart of public debate in the years or decades to come.
  • Ecology. We have to take care of our planet. If not for the planet itself, at least for the sake of our species. I try to reduce my environmental impact as much as I can, but I’m no extremist either.
  • This brings me to one of my life’s motto : extremes are always bad, whatever they are. It is never black and white. It’s not gray either. It’s a rainbow.
  • Self Improvement. Although there is a common hoax that tells us that when we’re past our 20’s we start decaying (I’m exaggerating a little, but not that much), I believe we can always improve ourselves. This comes with a deep understanding of who we currently are, and that life is always changing. Accepting change and embracing change is at the core of my life. This is why I like meditation and the Buddhist philosophy. I also use tools to enhance my memory. Back in the 1990’s, I invented for myself a spaced-repetition learning program to learn vocabulary in other languages, although I had no idea that it was actually called a spaced-repetition learning program! Then Anki appeared and I’ve been using it since then. I strongly believe that tools like Anki and others such as the Loki Memory Palace (to memorize series of words) or the Major System (to memorize numbers) should be taught in school at an early age. As an advanced species, we should also get rid of the “Qwerty” keyboard (or “Azerty” in France), especially on touch screen devices, I’ll write an article about this.
  • Teaching. Sharing my knowledge with others has always been a passion. In my University years, I spent a lot of time teaching to children who had problems in school. I was also a teacher during my PhD. This blog is definitely about sharing knowledge with you.
  • Many more subjects that I would like to develop. I have found out that every subject becomes more and more interesting as soon as you learn more about it. Even football teams or cars can get interesting, but I still try to keep some priorities and those are not in my list. 🙂

As you can understand, my main problem in life is that days only have 24 hours and I get to do only what I can do within that limited time frame. 🙂

Finally, you can find me on Diaspora, Mastodon, LinkedIn, Facebook and Twitter but I’m rarely active there.

Enjoy!