When refactoring the server from Lua to Go, the core idea was a three-way separation:
- Game Logic
- Everything related to the board state itself.
- Server Logic
- Everything connecting the client and the server.
- Move Engine
- Everything that measures the board state and results in the creation of a valid move set.
The last one was the most vague, but the reasoning for this split is these three core functions were all initially combined in one file. By moving to a three component structure, there is a lot to gain in terms of functionality and efficiency.
During this migration, the MoveEngine code ended up changing quite a bit. The processing of new moves and the means by which new moves were added in was a significant challenge in Go. Namely finding the right way to use channels, mutexes, and wait groups to achieve the desired results.
In the end, the best way this problem was conceptualized was a rather simple buffered channel and worker pool structure. One main thread loops until either:
- the time for the evaluation cutoff is reached or
- the # of pending moves and running workers in the pool are both 0.
With this structure, a large enough buffer, and some guard rails to prevent deadlock, the move evaluation engine is capable of evaluating significantly more move lists for a given turn in a fraction of the time the current implementation does; roughly increased from ~160-200 move lists per second to ~3,000-4,000 move lists per second.
While the work on the new and improved Move Engine is well under way, there is still a lot to do before release to the production environment. Along with the reworked move engine, all game logic has been reworked and optimized along with some board validation logic changes that should improve the overall efficiency of the server and theoretically increase the maximum player population without requiring upgrades to the server.
There are a lot of updates to come with the roll-out of the new server code: dynamic & preset computer opponents, updates to play menu / queue cycle, skill-based matchmaking (based on ELO), as well as more content updates once the server update and Steam rollout have settled in. The next DevLog will go over the initial concepts behind the Earth set, what to expect playstyle-wise, as well as some sneak peaks at some piece art for the new set.

Leave a comment