• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Windows AI Help Please

M

Marxsoul333Gaming

Guest
I just started a Super Bomberman fan game called Super Bomberman Z, and so far, I have 4 player mode in-tact. I just need some pointers on how to make the AI of the other Bombermen. I need the Bomberman to lay a bomb in front of breakable blocks, walk away from the bombs they lay, and continue. This goes along with the Bomberman engine I'm sure you've heard of. Maybe...
 
This is a very broad question and so difficult for members to answer. Also limits it to people who have played bomberman. And don't know how familiar you are with different ai coding concepts... I recommend you start trying to develop your ai and then if you get stuck with a particular problem, ask about that - will get more responses.

As a starting point for ai, I recommend looking at the mp functions in gamemaker for motion planning. Someone who knows bomberman may give a better answer, but as no responses yet I thought I'd try and help :)
 

TheouAegis

Member
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
  1. For every bomb on the field (including mine)...
  2. Is it on the same horizontal axis or the same vertical axis that I am on or approaching?
  3. If so, is the bomb's blast radius greater than or equal to my horizontal or vertical distance from it?
  4. 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.
  1. Is there a bomb on the horizontal axis above me? If yes, remove upward mobility from the pool.
  2. Is there a bomb on the horizontal axis below me? If yes, remove downward mobility from the pool.
  3. Is there a bomb on the vertical axis left of me? If yes, remove leftward mobility from the pool.
  4. Is there a bomb on the vertical axis right of me? If yes, remove rightward mobility from the pool.
  5. Is my current direction in the pool?
  6. If yes, keep moving in my current direction, else pick a random direction from the pool.
  7. 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.
 
M

Marxsoul333Gaming

Guest
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
  1. For every bomb on the field (including mine)...
  2. Is it on the same horizontal axis or the same vertical axis that I am on or approaching?
  3. If so, is the bomb's blast radius greater than or equal to my horizontal or vertical distance from it?
  4. 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.
  1. Is there a bomb on the horizontal axis above me? If yes, remove upward mobility from the pool.
  2. Is there a bomb on the horizontal axis below me? If yes, remove downward mobility from the pool.
  3. Is there a bomb on the vertical axis left of me? If yes, remove leftward mobility from the pool.
  4. Is there a bomb on the vertical axis right of me? If yes, remove rightward mobility from the pool.
  5. Is my current direction in the pool?
  6. If yes, keep moving in my current direction, else pick a random direction from the pool.
  7. 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.
Thank you so much for the tips! I'll do most of the basic things, but I might be back to ask how to type some of the stuff you said into the code later. XD
 
M

Marxsoul333Gaming

Guest
I was unable to add the pac man ghost AI, as the cpu just stood doing nothing but getting exploded by the timed bombs he lays. :'( By any chance could you give my a few snipets of code?
 
T

Tyler Logsdon

Guest
I was unable to add the pac man ghost AI, as the cpu just stood doing nothing but getting exploded by the timed bombs he lays. :'( By any chance could you give my a few snipets of code?
What exact code are you using?(go to object and click show information and copy and paste that here)
 
T

Tyler Logsdon

Guest
About that... I kinda just deleted the cpu object because it didn't work. :'(
Lol don't feel dumb i do the same thing pretty often...

Just try to create an AI to the best of your ability like the dude up there described(in pretty good detail). Just translate what he said into full to the best of your ability
 

TheouAegis

Member
Oh yeah, one of the things you have to be careful with when programming Bomberman clones is the bomb collision. You'd need to check for any collisions with any players when the bomb is first planted, set a variable to denoting which players it collided with once planted. Then when the player tries to move and detects a collision with a bomb, check if the variable is set in the bomb for that player.

I could give you an example as I'd do it, but then FrostyCat would harp on me, so I'll do it in the most basic way possible.

Code:
//in the bomb object's Begin Step event (so it's run before the players can move)
    if place_meeting(x,y, player1)
        p1collision = true else p1collision = false;
    if place_meeting(x,y,player2)
        p2collision = true else p2collision = false;
    if place_meeting(x,y,player3)
        p3collision = true else p3collision = false;
    if place_meeting(x,y,player4)
        p4collision = true else p4collsion = false;
Code:
//for player1
with instance_place(x+hspd, y+vspd, obj_bomb);
{
    if !p1collision    //check if the variable wasn't set to true
    {
        other.hspd = 0;
        other.vspd = 0;
    }
}
 
Top