Skyyker – 9ème
Preliminaries – Re-produce the behaviour.
First step, it was mandatory for me to reproduce the environment. It took me 2-3 nights sessions to perform it, and I really insist on the importance of this step!
Being able to debug on codingame is not always easy (I have seen that some people like oook are coding their own visualization, awesome!). To debug it, I computed
all the turns in advance during the first loop, and then compare each turn with my simulation and print the differences. Thanks to this rigorous steps, I have
worked without glitch during the entire contest. This allows to focus only on strategy.
Strategy
I don’t really know if what I have done has a name, but I would describe it as a mix between a Monte Carlo and a “basic” strategy:
The basic strategy
The first version was very “basic”: if you are going to die find a safe place, else shoot the nearest enemy. Then I have added some upgrades:
- if an enemy is shoot, don’t focus another one until he die
- set a random minimum distance before shooting unless you can kill him in one shot – to do so focus the next data point
- if I am in dangerous zone (3500 = safe zone(2000) +
max move(1000+500)), try to find the best spot --> hard to find and nearly useless… ! -_-’
The random strategy
In order to limit the random actions I have added rules:
Shoot rules
- select a random target: I have limited the random selection by removing enemies that have the same amount of life and focus the same data point: only the closest to the data
point was kept.
- if an enemy is shoot, don’t focus another one until he die (same as basic strategy)
Move rules - 2 possibilities:
- move in direction of a random data point (percentage:1/3)
- move in a random point restricted by an area around my target enemy
Let shake it all!!!
On every simulation, I was computing random parameters that were remaining unchanged during the entire simulation:
- number of random moves (between 1 and 8)
- number of first basic moves (between -10 and 10 reduced to 0 if negative)
- percentage for attack / move (between 10% and 100% of attack)
- minimal distance before shooting (between 2020
and 5000)
- Boolean to focus data point (5%)
So, my algo could be a mix like:
2 BASIC ACTIONS, 7 RANDOM MOVES, BASIC ACTIONS until the end
0 BASIC ACTIONS, 3 RANDOM MOVES, BASIC ACTIONS until the end
And, obviously, I kept the simulation with the best score (if same score, I kept the one with less moves)
Important informations
- always work with distance squared in order to avoid the cost of a root
- have a table [distance <=> shoot power] for performance (only 14 possible shoot power)
- compute the maximum score at every turn of your simulation. If it is less than your best simulation, stop the simulation and start another one. Truly important rule! Avoid useless simulations.
- limit the number of computation by the time (for me 995ms for the first turn, 95ms for others)
Conclusion
Good: Really interesting contest and I truly love when it last for 2 weeks! With such duration it is possible to have a good solution even without being able to code everyday =).
Rules were very well described (only the hesitation between rerun or not were not great – (it would not really impact me because my submit were pretty stable; but the information must be known before the end)
Bad: Not having easily the sum of the test cases scores. The life points of the enemies on the screen… Not described rules on submit.
A great achievements for me during the contest: 1st position with my language (Java) =D
And a special thanks to all the codingamers with whom I have exchanged on the chat
P.S: Should I add a potato?