This is a game strategy that I implemented for Russian AI Cup 2017: Code Wars in November 2017 - January 2018. Russian AI Cup is an annual online competition between game strategies. This year's rules (both in English and in Russian) can be found here.
Noteworthy points:
- Main challenge: the given API doesn't allow to control units directly. Instead, you should control "a virtual computer mouse" as the only way to select units is by specifying coordinates of a bounding rectangle.
- With the given API, it's not easy to chain different actions (you can execute only one per turn). In order to do that and to avoid chaos in code, I implemented the Command design pattern: see base class
Action
and 10 classes derived from it. - Several times (1, 2, 3) I used the same approximation technique to estimate desired min/max values fast: instead of doing heavy precise calculations, I subdivide the playing field into
n
equal squares (wheren
is the field's side length) and treat each such square as a single point containing all of the square's units. - Entry point is
MyStrategy
class. Each tick, entry point isMyStrategy::move()
. - Planned actions are stored in
std::deque
(urgent ones are added to its head when its first element stands for the beginning of a new chain of actions, all the other ones - to its tail). - I implemented two different strategies for games with and without buildings (in
DecisionMakerForGameWithBuildings
andDecisionMakerForGameWithoutBuildings
respectively). However, they also share some common methods. These methods reside in the base classDecisionMaker
, as well as in its helper classesNuclearAttackHandler
,MotionlessnessChecker
andVehicleValueEstimator
. - This repository contains only my code. Files which define the game rules and API for the strategy can be downloaded here.
As for results,
- In the official track, I advanced to Round 2 (Top-360 out of about 1000 participants) and finished on the
123rd
place. - In the "Sandbox", I finished on the
177th
place. - Unofficially, the "Sandbox" is still running, and my strategy is generally climbing upwards by small steps - currently around
150th
place.