snake-ai-pytorch
snake-ai-pytorch copied to clipboard
How to fix AI snake deadend trap?
Hi, im trying to solve that snake deadend trap, but I couldn't figure it out, here is my fork with some fixes and enhancements https://github.com/PayteR/snake-ai-pytorch
I created the is_collision_predict
function inspired by is_collision
. There I added detection if when snake turns into some direction and his body is there then it returns True
https://github.com/PayteR/snake-ai-pytorch/blob/ab13675964f179179d77987c8a6e386d92a6b60b/game.py#L117 Code is ugly little bit but is believe it's correct.
Now i had worse results than without it, how is that? I didn't added any new param, I just notice algorithm that there is danger if turns to the deadend. Thx for suggestions.