Gomoku

May 31, 2019 - December 31, 2019
Python TKinter Numpy Artificial Intelligence MCTS

Background

Gomoku is a board game played with Go pieces on a 19x19 Go board. The objective of Gomoku is to align 5 of your Go pieces in a line (diagonal, vertical or horizontal) before your opponent does so.

Dr. Chen, a Computer Science professor from The University of Texas Rio Grande Valley, organized a Gomoku team with Oscar Garcia as the lead researcher. The team focused on developing a Python Gomoku AI to compete against other Gomoku AI's in the global Gomocup tournament. After 1 year of development I joined the team as a Research Assistant; I dedicated the first weeks to researching topics and understanding the codebase since I had no experience with Python, Machine Learning, or Artificial Intelligence.

My Contribution

My first contribution was code documentation. My documentation consisted of control flow vizualizations, architecture diagrams, and clarifications of complex code like lambdas and list comprehensions:

[[X[i,j] for j in range(X.shape[1])] for i in range(X.shape[0])]

Additionally I implementied the AI communication with the Gomocup AI's. Using multithreading, pipes, and sub-processes I connected our python project with the Gomocup AI .exe files. The connection was able to run in a background thread, allowing for our AI to communicate with other AI's while also calculating our next move. Implementing the connection in this manner allowed for the AI to run multiple games against multiple AI's autonomously.

Aftwards I implemented a move history. By storing all the board states we could move back and forth in time and figure out what move lead to a loss. We combined the move history with the background thread and let the AI gather enough losing pattern data through a long period of time.

I also assited Oscar Garcia, the team lead developer, implement heuristic search algorithms like the Monte Carlo tree search (MCTS). The MCTS was implemented with several parameters and tweaked to fit our datastructures. We were able to find excellent parameters such that the exploration and exploitation process increased our win rate by 50% against some of the top Gomocup AI's.

My final contribution consisted of interface tweaks and bug fixes. For the interface, I added several "skins" to the board to make it customizable. I also added a board size changer since Gomoku is played in different board sizes, and because the Gomocup AI's also accept different board sizes as parameters (altough the main size is 19x19). I also found bugs that caused the AI to crash, become frozen, or choose the wrong move (or not the most optimal). I presented these bugs to the team and we fixed them.

Results

I'm proud of my accomplishments and the ideas I brought to the team. I was able to learn new Programming langauges, techniques, data structures, and new algorithms and implement them into a large codebase within a matter of weeks.

The communication bridge between our AI and the Gomocup AI's dramatically increased the intelligence of the team and AI. By viewing the process of top Gomoku AI's we could learn and exploit every Gomocup AI strength and weakness; the move history also contributed in the same manner. As previously mentioned, the communication bridge and the move history increased our win rate by 50% against top Gomocup AI's!