Codingame Coders of the Caribbean AI in C++ for an 1 week contest.
- Rule based : custom pathfinding (works not great) to get the nearest Barrel and fire on the closest enemy when ability is ready.
- Full random : get random actions and simulate game with depth 5, and play the actions with the highest score
The rule based strategy was used to get out the Bronze league. It's no more used since its efficiency is a lot lower than the full random strategy.
Ally ships health
Rum barrel distance
Ally ships speed
Max ally ship health
Distance to ally ship
Enemy position behind stern
The actions computed by the full random strategy are only movement related.
WAIT
actions and SLOWER
with speed already equals to 0
are replaced with FIRE
and MINE
.
The latter are computed by a heuristic function which simulate enemy moves with also a full random strategy with his
own eval
function.
- Compute the
FIRE
andMINE
actions in the random strategy - Compute enemies actions in the simulation
- Use something more like genetic algorithm to converge to the optimal solution.
- Use brute-force method when having enough time (1 ship left)
- Find the right hyperparameters (a lot empirical testing)
- Better game engine
- Use all C++ tricks to improve overall performance
- Precompute distances and neighbor calculation
Since Codingame does not use the gcc optimization, the STL is very slow. So, I used simple List
implementation.
It has begin
and end
iterators, so it is compatible with the C++11 for loop.
The code can be improved using static allocation instead of using new
and pointer. The performance is not great.
The code related to the engine is inspired a lot by the Codiname Java Referee.
Ranked 26th with this bot