# Bomberman Mechanics for AI

Discuss game development design and post your game ideas

### » Thu Sep 28, 2017 4:22 am

Nice effort my friend! Remind me of my stalled Bomberman prototype:
viewtopic.php?f=180&t=172317&p=1034492#p1034492
B
133
S
55
G
24
Posts: 803
Reputation: 24,414

### » Thu Sep 28, 2017 4:03 pm

Since the game level is a board and people move on squares in a grid, you could find the square you want to move to, mark that sqaure as 0. Then go outawards in a circle pattern so the next squares surrounding that would all be 1, then go outwards again and all those squares would be 2 etc until each square on the board is covered. Dont count squares with a wall as you cant move there. Now all the person who is moving needs to do is to always move each step towards the sqaure with the lower value to the square its currently standing on to move there.

You could artifically inflate the value of squares under certain conditions to make those squares less attractive to move to, such as if an enemy drops a bomb then that would add say 100 to the sqaures value and would radiate 99, 98, etc for the bombs explosion range. The person would avoid those squares and find a path around them.
B
14
S
4
G
1
Posts: 81
Reputation: 1,143

### » Sat Sep 30, 2017 6:54 pm

For making the ai avoid explosions you could use
https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm
It's kind of along the lines of what mOOnpunk said, but instead of a weight, we just search from the player to the closest non blast radius area. That brings me to another idea, you can use an array as a grid of the level and loop over the bombs and set all the locations that will have explosions. That gives a simple lookup with events.

https://www.dropbox.com/s/ks3feo35bgyo1 ... .capx?dl=1

Basically that's the first half of an ai. The blue guy will move out of the blast radius of placed bombs if it can without stepping into fire. It doesn't consider the time left before a bomb goes off which is something most players don't bother with. they just stay out of range of bombs.

The second half would probably be moving and placing bombs. Finding where to bomb could be done with a similar breadth first search and then evaluating what a bomb would destroy (enemy or block) for each grid location considered.

The logic would be:
if the ai is in a blast radius
move to same place
else
find a good place to bomb, move there and place bomb

To keep the ai from bombing itself you can also check for if there's a place to escape to before placing the bomb.

Anyways maybe some of those ideas are helpful. More advanced stuff can probably be considered later, but the basics are always good first. Also in the example everything is grid based but the motion doesn't have to be. The units need not even stop of grid centers, but that's something to figure out for another day.
B
100
S
38
G
134
Posts: 5,555
Reputation: 85,323

Previous