Othello(); Pt. 3 The AI

This is it. The moment I have been waiting for! With the actual game part complete, all that is left is to program the AI (the reason I started this whole project).

My theory on how the AI will work is pretty simple:
1) Check all valid positions
2) Pick the position with the highest outcome of flipped pieces.

The first step is to eliminate all the spaces which are not possible. We know that a space is only valid if it can flip at least one piece, so that means that one of the bordering spaces of an empty piece has to contain at least one piece of the opposite color.

In order to check for this, I run a 3x3 grid over every space, and if the center is empty, then it checks the surrounding spaces for one of the opposite color. If there is one of the opposite color, then it marks that space as "possible." Even though this will still mark spaces that are not technically possible, it narrows it down enough to be useful. The result is this:

From here, I can the "tryFlip()" function on each of those red spaced, and see how many pieces each one will return. All the spaces that flip pieces are placed in an ordered list from least amount of pieces flipped, to most amount of pieces flipped, allowing me to select the lowest for an easy difficulty, or the highest for a harder difficulty. If there are no more possible spaces, then the game ends.

All in all the AI part was really simple, and kind of a letdown considering how much work had to go into the game before I could start working on it, but I still learned a lot.

The finished game can be downloaded and played here:


  1. Hi Zach, I've been watching your Autodesk tutorials for these past few weeks and I found them to be really helpful and easy to follow! I am by no means a proficient 3D modeler at all but I always wanted to learn 3D and finally decided to start learning it. Since you're very good at 3D modelling I would like to ask whether you've been attending courses specifically in 3D designing before, or perhaps you simply learned it all by yourself? Do you think it is necessary for people who wants to try learning 3D modelling for video game development to at least join a course or sign up for classes? What advice or suggestions can you give for someone who wants to learn 3D independently? (Pardon my English) Regards, Kuriafica from Indonesia.

    1. Always glad to see people learning from my videos :)

      What I know about 3D modeling is entirely self taught through experimentation, youtube tutorials, and a lot of practice.

      Whether or not you should take a course in 3D modeling depends on what you would like to do, and why you are learning 3D modeling in the first place.

      If you are learning 3D modeling for a hobby, or plan to do independent work, either as a contractor, starting your own animation/game studio, etc., then it is entirely possible to do it on your own without any expensive courses. There are tons of resources at your disposal that should make learning easy and enjoyable.

      However if you are planning on working for somebody else (especially in a larger scale, like a big animation/game studio), then a degree is something you should look into, not for the knowledge, but for the piece of paper.

      Just remember, it doesn't matter how much you learn, if you don't practice and constantly push your envelope, you won't get better.

      Also, wrapping up a lot of personal work IRL, so more 3DS videos coming soon


Post a Comment

Popular posts from this blog

I need to switch to Linux... BAD (rant)

Live Streaming is... weird

Accountability(); Pt. 2 From failure to success