Jump to content



1

Enemies moving in maze?


13 replies to this topic

#1 yuppicide OFFLINE  

yuppicide

    I am the Black Knight. Give me your money!

  • 6,933 posts
  • Location:New Jersey

Posted Fri Sep 12, 2008 1:02 PM

Let's say I draw a maze in BB as a playfield.. we'll say it's 32 x 30 using Superchip.

How would I implement an enemy or two that moves around the maze similar to Maze Craze?

I am trying to think of a way to do this, but all I am coming up with is the following:

- Randomly pick a number from 1-4.
- If 1 then enemy moves up, if 2 moves right, if 3 down, if 4 moves left.
- Game checks to see if enemy has collided with the playfield. If yes then go back to randomly pick another number. If no then drawscreen showing enemy in
new position.

The problem with this is, the enemy will have some crazy movements.. and may sometimes just move back and fourth like an idiot.

I don't want it to specifically chase and hunt down the player.. I want it to be somewhat stupid, in which if it's chasing the player, the player can duck down a hall and the enemy may or may not follow him.

Edited by yuppicide, Fri Sep 12, 2008 1:06 PM.


#2 SeaGtGruff OFFLINE  

SeaGtGruff

    River Patroller

  • 4,543 posts
  • Location:Georgia, USA

Posted Fri Sep 12, 2008 2:37 PM

View Postyuppicide, on Fri Sep 12, 2008 3:02 PM, said:

Let's say I draw a maze in BB as a playfield.. we'll say it's 32 x 30 using Superchip.

How would I implement an enemy or two that moves around the maze similar to Maze Craze?

I am trying to think of a way to do this, but all I am coming up with is the following:

- Randomly pick a number from 1-4.
- If 1 then enemy moves up, if 2 moves right, if 3 down, if 4 moves left.
- Game checks to see if enemy has collided with the playfield. If yes then go back to randomly pick another number. If no then drawscreen showing enemy in
new position.

The problem with this is, the enemy will have some crazy movements.. and may sometimes just move back and fourth like an idiot.

I don't want it to specifically chase and hunt down the player.. I want it to be somewhat stupid, in which if it's chasing the player, the player can duck down a hall and the enemy may or may not follow him.
How about this idea:

(1) Pick an initial direction and let the enemy move that way until there's an intersection, cul-de-sac, or corner.
(2) If the enemy hits the end of a cul-de-sac, or a wall at the corner of a turn, randomly pick a new direction.
(3) If the enemy enters an intersection, randomly pick a new direction.

Similar to your original idea, except the enemy stays headed in the same direction until hitting the playfield or entering an intersection.

Michael

#3 Random Terrain ONLINE  

Random Terrain

    Visual batari Basic User

  • 20,911 posts
  • Controlled Randomness
    Replay Value
    Nonlinear
  • Location:North Carolina (USA)

Posted Fri Sep 12, 2008 3:10 PM

I don't know if it will help, but here is a thing I was working on when batari Basic was older:

http://www.atariage....s...t&p=1586075

The code has been edited so it will run using the latest version of bB.

Edited by Random Terrain, Fri Sep 12, 2008 5:20 PM.


#4 atari2600land OFFLINE  

atari2600land

    Quadrunner

  • 6,491 posts
  • All hail the zyzzyva!
  • Location:Salem, Oregon

Posted Fri Sep 12, 2008 3:51 PM

Here's another thing you could do: set the maze intersections be the similar numbers up, down, left and right, and then keep track of the enemy's distance and once it reaches that point, have it either continue along its way or choose a new direction. It's kind of hard to explain what I mean, so I made a little program so you can see better.

Attached Files



#5 Nukey Shay ONLINE  

Nukey Shay

    Sheik Yerbouti

  • 20,458 posts
  • Location:The land of Gorch

Posted Fri Sep 12, 2008 3:53 PM

IIRC, the "cops" in Maze Craze to not use any AI deduction. Each of them just always turn a specific direction when faced with an intersection. If that turn is invalid, 90 degrees from that is tried (and so on). In this manner, the entire maze is explored one turn at a time.

#6 SeaGtGruff OFFLINE  

SeaGtGruff

    River Patroller

  • 4,543 posts
  • Location:Georgia, USA

Posted Fri Sep 12, 2008 4:14 PM

View PostNukey Shay, on Fri Sep 12, 2008 4:53 PM, said:

IIRC, the "cops" in Maze Craze to not use any AI deduction. Each of them just always turn a specific direction when faced with an intersection. If that turn is invalid, 90 degrees from that is tried (and so on). In this manner, the entire maze is explored one turn at a time.
In theory. I always thought that you could traverse an entire maze that way, but then I ran into a maze in one of my NES games (sorry, I don't remember the name, but I think it might have been "Might & Magic"?) where always turning right did *not* take you all the way through the maze, and there was a message written on one of the walls that said "Remember, never do anything right," or something like that.

Michael

#7 Glenn Jupp OFFLINE  

Glenn Jupp

    Star Raider

  • 87 posts
  • Location:London, Ontario, Canada

Posted Sat Sep 13, 2008 11:21 AM

View PostSeaGtGruff, on Fri Sep 12, 2008 6:14 PM, said:

In theory. I always thought that you could traverse an entire maze that way, but then I ran into a maze in one of my NES games ...

Yeah, the "ejection loop" is an old trick of maze makers. Check the simple pic I attached. The maze on the left is a "simply" connected maze. Always taking the right-hand path will get you to the goal and out again. But the maze on the right has a loop that will take you around and back to the start, but the path to the goal will be opposite your "always turn ***" rule.

Random Terrain's Ruins game makes randomized mazes, but it looks to me like they will most always have a loop round the outside and a few loops throughout the interior. Always turn *** would get the AI stuck fast.

Back to Yuppicide's problem, maybe you could give the AI a certain probability of choosing the correct path to catch the player, and otherwise it goes in a random direction? That could give you more options for selecting game difficulty, letting the player choose how smart the AI is.

Attached Thumbnails

  • maze_ex.JPG


#8 Nukey Shay ONLINE  

Nukey Shay

    Sheik Yerbouti

  • 20,458 posts
  • Location:The land of Gorch

Posted Sat Sep 13, 2008 2:12 PM

View PostSeaGtGruff, on Fri Sep 12, 2008 3:14 PM, said:

In theory.

In fact. That is how Maze Craze functions (which contains no looped paths).

#9 SeaGtGruff OFFLINE  

SeaGtGruff

    River Patroller

  • 4,543 posts
  • Location:Georgia, USA

Posted Sat Sep 13, 2008 2:33 PM

View PostNukey Shay, on Sat Sep 13, 2008 3:12 PM, said:

View PostSeaGtGruff, on Fri Sep 12, 2008 3:14 PM, said:

In theory.

In fact. That is how Maze Craze functions (which contains no looped paths).
Sorry, I meant in a general sense, not specifically in reference to Maze Craze. I don't know what the mazes in yuppicide's game are going to look like, so I was pointing out that "always turn right" (or "always turn left") might not let the enemies traverse the entire maze. I've been a long-time user (and still am) of the "always turn right" rule of thumb when exploring mazes in games, and it *usually* serves me quite well. :)

Michael

#10 yuppicide OFFLINE  

yuppicide

    I am the Black Knight. Give me your money!

  • 6,933 posts
  • Location:New Jersey

Posted Mon Sep 15, 2008 7:28 AM

What I am thinking (and have thought for many years) is a Maze Craze like game with multiple screens. The enemy/ies would be confined to one screen so they can't follow you to the next.

I would have say 10 or 15 screens. These are all pre-made up, not random. But the thing is the entrances and exits to each screen are all in the same location, so the screens can be put together in a random order.

#11 SeaGtGruff OFFLINE  

SeaGtGruff

    River Patroller

  • 4,543 posts
  • Location:Georgia, USA

Posted Mon Sep 15, 2008 11:20 AM

View Postyuppicide, on Mon Sep 15, 2008 8:28 AM, said:

What I am thinking (and have thought for many years) is a Maze Craze like game with multiple screens. The enemy/ies would be confined to one screen so they can't follow you to the next.

I would have say 10 or 15 screens. These are all pre-made up, not random. But the thing is the entrances and exits to each screen are all in the same location, so the screens can be put together in a random order.
I made a random maze generator in bB a few years ago that could be modified to work with a Superchip playfield. I'll do an update of it, in case you're interested in checking it out.

Michael

#12 yuppicide OFFLINE  

yuppicide

    I am the Black Knight. Give me your money!

  • 6,933 posts
  • Location:New Jersey

Posted Mon Sep 15, 2008 11:50 AM

I would love to see the maze generator updated, sure.

I have three games I am working on separately and I was thinking maybe I could squeeze them onto a larger cart all together somehow.

I picked up a Superchip cartridge with 8K and I'm going to be testing them soon on real hardware. I need to pick up a rom programmer first.

I'm going to pick up the BX32 Batupo based on some recommendations here. My problem is money right now since I am moving soon. The programmer is $149.50 and I will need an eraser as well and those I see are $99. :(

Edited by yuppicide, Mon Sep 15, 2008 11:56 AM.


#13 Random Terrain ONLINE  

Random Terrain

    Visual batari Basic User

  • 20,911 posts
  • Controlled Randomness
    Replay Value
    Nonlinear
  • Location:North Carolina (USA)

Posted Sat Sep 20, 2008 11:54 PM

Since SeaGtGruff recently posted sprite to playfield conversion info, I decided to rip the guts out of Ruins, update it with the new conversion info, and stick it in the maze that atari2600land posted in this thread.

Below is a simplistic Pac-Man-ish demo where you can move around the maze. You can move faster by holding down the fire button. There is no collision detection in this demo and the bad guy is dumb (no AI added yet). The bad guy just wanders around the maze without paying any attention to you.

Here's the .bin file to use with your favorite emulator:
Attached File  maze_2008y_09m_21d_0128t.bin   4K   78 downloads

Here's the .bas file if you want to look at the code:
Attached File  maze_2008y_09m_21d_0128t.bas   9.53K   59 downloads


Since I spent time ripping out the guts of Ruins and updating the code, I'll probably make a complete game based on this demo (with different mazes and sprite data).

#14 Random Terrain ONLINE  

Random Terrain

    Visual batari Basic User

  • 20,911 posts
  • Controlled Randomness
    Replay Value
    Nonlinear
  • Location:North Carolina (USA)

Posted Tue Oct 21, 2008 2:10 AM

As I said above, I'm just going ahead and making a game based on the demo I posted here. Looks like it will be my first game instead of that scrolling game I was working on. What I thought would be my first game will end up being my second. Thought I would let you know that I discovered a couple of mistakes in the code posted above, but I fixed it in the game I'm working on. I hope it won't be too long before I can post the new code. I need to add sound effects and some 'AI' first.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users