Join GitHub today
A naive attempt at being aggressive #4
The original Robosnake tries to play defensively, keeping to the centre of the game board. This was done for a few reasons: firstly, because the original implementation was against the 2016 API which would place gold in the centre, secondly, because it forces the enemy to the outside which makes it easier for them to get pinned against the edge of the arena, and finally, because head-on-head collisions were never fully supported in minimax.
With PRs #2 and #3 in place, we can now act more aggressively. This is a simple change that scores the game board higher the closer we are to neighbouring squares of the enemy's head (replacing the centre).
I'm actually shocked by how well this works. Using our win conditions from last year (17x17 board, 10 food) and a recursion depth of just four, we have a 100% win rate against all of my test snakes, except for YND and old Robo. (The sample size is 5 games against each snake). This includes powerhouses such as BTaS (sorry Tyler), Come Slither (sorry Stew), and D.Va...
Versus the 2017 Robosnake we have a 60% win rate.
Increasing the recursion depth improved our performance against YND. With a recursion depth of 6 we beat YND 40% of the time, and with a recursion depth of 8 we beat YND a whopping 80% of the time (however I had to increase the api timeout to 2s as we're only running on a t2.medium in dev). Given the small sample size however I'm not completely confident in these results.
Update Jan 26th:
I've increased aggressiveness even further, by modifying the snake to ignore food (more specifically, food won't affect the board weighting) unless our health is at 40 or less (this number can be customized in http.conf).
With this change, we beat YND 90% of the time played over 20 games on a 17x17 board with 10 food, using a recursion depth of 6.
I also fixed a small bug in how food is weighted so that no two food will have the same weight, even if they are equal distance from our head.