AI HELP ! Find a "safe" spot on a 2D grid.
Hello.
I am developing AI for a 2D board game and I am thinking of what is the best way to find a "safe spot" on the 2D grid.
As an example:
A human player has figures that can move and then shoot. He can play once with every figure.
Figure 1 - moves like a Rook, but only 1 space away -> shoots in chosen diagonal
Figure 2 - moves like a Queen, but only 3 spaces away -> shoots in chosen perpendicular direction
Figure 3 - moves like a Knight -> shoots all adjacent perpendicular enemies
AI Figures:
I have an enemy MAIN unit that should avoid getting hit (if it gets destroyed, the AI will lose the game). That unit can move one space to the LEFT / RIGHT or STAY in its position(basically stays on the same row all the time) And there are two other enemy types, that for now just move and try to attack the player figures(They will not try to protect the MAIN unit )
My brain has tinkered the following so far :
For each position of the MAIN unit can move to
Get all player figures
Temporary move each figure to each possible movement position
Check possible shoot directions for each position
So for player figure 1 I would have to move it to the 4 possible positions, check all shooting directions in each(4 diagonals and check each square along for any AI units that will block the shot)
I checked with Alpha Beta pruning algorithm for chess, but I think it will be too complex to implement for my game as all units can move each turn and they can also shoot.
I personally think this is a very straightforward approach and it might be very slow (if there are a lot of figures on the board, say like chess). Are there any smarter ways to do that?
Your answer
Follow this Question
Related Questions
Grid-based 2D game (turn based): How should I get started? 1 Answer
Drag and Drop Problem 0 Answers
One large 2d grid or multiple small ones? 1 Answer
Controlling two characters simultaneously on a grid 1 Answer
tile movement Animation problem 0 Answers