Closed mantono closed 6 years ago
I believe I have found the cause, but only if that cherry didn't spawn on snakes, but rather two snakes collided trying to eat it, killing them both. It's impossible to tell if that's what happened from the data available to me, so I'm going to assume this explanation until corrected:
If you look at the logic in Session.tick(), the game moves all snakes first and checks for collisions second. In Session.checkForCollision(), it kills any colliding snakes before they get to eat the cherry that may be in the same square. This would mean that two snakes simultaneously entering a square with a fruit in it will both die and neither will get the fruit, basically causing a lethal fruit mine for any snakes that don't check whether a fruit square is non-lethal before pursuing it.
I'm not sure this should be considered a bug, but if it shouldn't, then the possibility of this happening should certainly be documented. I also have a vague memory of this being a conscious design decision, but that may well be my imagination.
/T
ps. @booski cancer is getting its ass kicked
Heh, no suprise with the number of bots. It's criminally inefficient and hence only stands a chance if it can hog the CPU.
Reproduced the situation. I've attached a replay showing what happens: greedybastards.zip
Interesting! That very much seems to resemble the situation I encountered. I do not recall if there was actually two snakes colliding head to head, but most likely that was the cause. I am bit surprised that I have not encountered this more often, since this should be a quite common way for snakes to die, but the replay clearly shows that it is possible.
I'm not sure this should be considered a bug, but if it shouldn't, then the possibility of this happening should certainly be documented. I also have a vague memory of this being a conscious design decision, but that may well be my imagination.
If this is an intentional design decision I will happily close this issue.
If you look at the logic in Session.tick(), the game moves all snakes first and checks for collisions second. In Session.checkForCollision(), it kills any colliding snakes before they get to eat the cherry that may be in the same square. This would mean that two snakes simultaneously entering a square with a fruit in it will both die and neither will get the fruit, basically causing a lethal fruit mine for any snakes that don't check whether a fruit square is non-lethal before pursuing it.
I will have to take this into consideration when programming future bots. Thank you for taking your time and looking into to this issue!
This can occur when, as demonstrated in the replay posted by @booski above, two (or more) snakes attempt to eat the same fruit in the same frame, and is an intentional design choice. It would be difficult to in a fair manner decide which of the competing snakes would get to actually eat the fruit before dying, a decision which can potentially have a large impact on the game if any of the snakes are a single point away from victory. Thus they are both killed, their intertwined carcasses acting as a reminder to other snakes - a reminder of nature's swift punishment for excessive greed.
I have run hundreds of games before and never encountered this. I do not know if there was some particular setting of this game that triggered this bug. This is not simply a graphical bug, the snakes did read the position of the faulty cherry from the list of fruits and were trying to get it (that's why there are so many dead snakes around it). The screenshot was not taken until the game was completed and not right after the faulty cherry appeared.
Game settings Board width: 60 Board height: 60 Pixel per square: 15 Fruits to win: 100 Ticks between fruits: 4 Ticks per unit of snake growth: 200 (!) Thinking time: 150 ms Game speed: 160 ms
ps. @booski cancer is getting its ass kicked