Hi there
I’ve created an AI system, that allows my CPU controlled player, to move thru a game scene (think a chess board, where player can only move left or right, hopping to a new position).
My issue is that, some board positions, are hazards and to create a more realistic AI, I want the AI to access the board.
The problem I am having is creating a solid method where the AI, can asses the board better and make shots that are less terrible.
Please see video, and if any one has any suggestions, please share.
Create a graph of each node in the grid. This can be as simple as an array.
Each node in the grid has some data associated with it (if it’s clear, a hazard, etc). Create a struct/class that can store this information. Populate every node in the graph with its corresponding data.
From this you should be able to assess information. For example you can use an A* algorithm to pathfind across the graph. Or you can grab sequences of neighbour nodes to test if any hazards exist in that sequence.
The game is voxel (mostly), I do have each ground unit and if it is hazard or not, stored, that I can reference.
My issue, is creating some real intelligence.
The video shows a pretty bad version of the intelligence. I have an earlier version I may use until I can sort something out. Essentially, it just methodically moves like a snake towards the hole. It works for the most part, but does not account for hazards and how to properly adjust if a hazard is met.
I am looking at various grid based A* Pathfinding tutorials.
One thing that I am wondering and hoping for some design input is, that my game, the player (CPU or othetwise) moves by jumping. So an obstacle, might not be an obstacle, as he can jump over it, tho of course, he can still land in it…
Then you’d need different agents who traverse the grid in different ways.
Also worth mentioning that Unity has built-in navmesh support and Aron Granberg’s A* solution is absolutely fantastic (I’d use it over Unity’s quite honestly).
Yes, I have used Unity’s NavMesh, and it is great, but my understanding of it, it is more for 3D, roaming games. Monsters walking around etc. My situation is a bit unique. I will be figuring this out today, I figure.
One thing that might help for jumping is you assign a cost for traversing each grid. For instance, if the grid contained marshland, it has a higher cost to travel across than if it is hard ground. So, if it was jumpable, it would have a higher cost, but it would still be an advantage compared to going around it. Then when it gives the path of the grid positions, you would have to change the animation and speed when going over that grid position.
My AI now makes the perfect shots… a little tooo perfect. Thats ok tho. I can now work backwards and add a little bit of variant to the aim, just so long as he is aiming correctly.
Check the video. CPU is red, I am blue. A few enemy obstacles, may clutter the clear precision of the AI, but its there.
Cheers
I don’t have anything to add to the answers, but I want to say that I like your design and layout for this game… this is what casual quick-to-access gaming is all about. Bravo!