Skip to content
No description, website, or topics provided.
C++ Makefile
Branch: master
Clone or download
Pull request Compare This branch is even with rdbrck:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
crow @ 4e39b23
json @ ed8516d

C++ Snek


##Dependencies## Boost C++


JSON for Modern C++

##Compiling## You will only need to install Boost the others will be handled by git submodules.

git submodule init
git submodule sync
git submodule update

##Strategy## I chose to use C++ so that I could get the most out of the 200ms execution time. For the web server I selected Crow, a C++ web microframework that was inspired by Flask. Lightweight, fast, and simple to use, it was perfect for this project. For JSON parsing I went with JSON for Modern C++ which has a very familiar syntax.

The strategy was very simple. At every turn, a flood fill algorithm was used to find dead ends and fill them. BFS was used to find the nearest food. In the early game, it would eat the closest food until reaching a size of 10. Then, a secondary strategy would kick in. If it was far away from food, it would BFS to the nearest food. Once close, it would A* back to two spaces from its tail, delaying until its health was low. When its health is less than the size path to the nearest food added with a buffer value, it would execute the path found by the BFS to eat the food. This strategy had a major drawback – enemy snakes could steal food from it while it was low on health, causing it to starve.

The snake came 3rd in its first battle, dying to a flood fill bug which did not allow it to grab the food it needed to survive. In its next battle, it lost a one on one to the eventual winner aptly named Better than Aleksiy’s Snake.

Next year’s snake will be improved by rewriting dead end detection, eating food that other snakes are trying to steal, and implementing alpha-beta/minimax to fully utilize the performance of C++.

You can’t perform that action at this time.