I would consider using a Pac-Man ghost AI code as your base, since Bomberman is essentially played on a grid. The enemy would be moving around walls and avoiding hazards (just like a Pac-Man ghost. Since BM is played within a grid, hazard checking is as simple as
- For every bomb on the field (including mine)...
- Is it on the same horizontal axis or the same vertical axis that I am on or approaching?
- If so, is the bomb's blast radius greater than or equal to my horizontal or vertical distance from it?
- If yes, move away from that axis
However, there of course will be multiple bombs on the field, so I'd suggest setting up a pool of directions.
- Is there a bomb on the horizontal axis above me? If yes, remove upward mobility from the pool.
- Is there a bomb on the horizontal axis below me? If yes, remove downward mobility from the pool.
- Is there a bomb on the vertical axis left of me? If yes, remove leftward mobility from the pool.
- Is there a bomb on the vertical axis right of me? If yes, remove rightward mobility from the pool.
- Is my current direction in the pool?
- If yes, keep moving in my current direction, else pick a random direction from the pool.
- If unable to move due to no pool or the only valid directions are blocked by a wall, move toward the nearest grid-snap that ideally does not have a bomb along its axis and wait.
Placing bombs is a bit trickier and requires knowledge of the powerup mechanics and such. On easy mode, the AI could just place bombs when available. On harder dificulties, the AI could be aware of all its powerups and plan accordingly based on the player's current relative position.