Python Forum
[PyGame] AI Techniques applied to a Game - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Game Development (https://python-forum.io/forum-11.html)
+--- Thread: [PyGame] AI Techniques applied to a Game (/thread-37442.html)



AI Techniques applied to a Game - insignia47 - Jun-10-2022

Greetings Everyone,

First of all, let me introduce my self. My name is inSignia and i am 24 years old. I need help implementing AI search algorithm techniques on a game (Snake game). BFS, DFS or AStar - i need to implement one of them on a snake game. I can implement them on a graph, but i dont have any idea how to start or implement them on an existing game code. I have a few game codes implemented by others but i do not understand them, is there anyone who could help me with my implementation or help me understand what the logic of the already implemented codes by some one else?
I need help please reach out to me!

Best Regards,
inSignia


RE: AI Techniques applied to a Game - deanhystad - Jun-17-2022

Do you know how to use BFS, DFS or AStar to find a solution to a maze? That is what you need to do here.

Your playing surface is a grid of cells. Most cells are open. One cell contains the goal. Some cells must be avoided. You take the current game situation (where is the goal, where are the snake segments) and create your graph. Pass the graph to the solver to get your next move. Repeat until you achieve the goal, get trapped or die.

If you playing field is large this is going to be very slow.