Author Topic: Maze generator  (Read 8862 times)

Jam0864

  • Contributor
  • Fanatic
  • **
  • Posts: 744
    • MSN Messenger - marmalade0864@hotmail.com
    • View Profile
    • Jam0864's Content Dump
    • Email
Maze generator
« on: 2007-03-22, 11:23:30 PM »
You know how SGDK has a maze generator in the map editor? I was wondering if it was possible to use this maze generator to generate random mazes at runtime?  ;) I was thinking of making a game where you had to go through mazes, and the system is not level-based. The idea is to make an original maze that the player hasn't done before, each time.  :) If that is too big a request, maybe a script to select a random map to play, so I can just make 40 or so mazes and make it choose a random one.   :D Any help on this would be great! ;D

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: Maze generator
« Reply #1 on: 2007-03-23, 06:57:20 PM »
I think I looked into this a while back and realized sadly that the maze generator 1) was not adequately exposed to be used by script, and/or 2) was not included in GDPlay.  However, if you're ambitious, you could try to re-create the functionality of the maze generator in VBScript or another VB component used by your VB script.  You'd look at the GenerateMaze function in the MapEdit class of the GameDev source code.

Jam0864

  • Contributor
  • Fanatic
  • **
  • Posts: 744
    • MSN Messenger - marmalade0864@hotmail.com
    • View Profile
    • Jam0864's Content Dump
    • Email
Re: Maze generator
« Reply #2 on: 2007-03-23, 08:23:30 PM »
Oh, ok. Is it possible to choose a random map to start up on then?

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: Maze generator
« Reply #3 on: 2007-03-24, 09:13:14 AM »
You can make a sprite with a starting point in the center of a circle and then a path that has 50 points around the edge of a circle.  Then put a function at each point that switches to a map.  Set the sprite to follow path random points.  Of course if you want to write some script code, you can just pick a random number with the Rnd function and map it to a map using a numeric index into the maps collection.

durnurd

  • Lead Lemming
  • Expert
  • Fanatic
  • *****
  • Posts: 1234
  • Games completed so far: 0
    • MSN Messenger - durnurd@hotmail.com
    • View Profile
    • Find My Ed
Re: Maze generator
« Reply #4 on: 2007-03-24, 02:12:51 PM »
Does the follow path random points pick a different one every time it is run?  I thought it was a predictable random generator.
Edward Dassmesser

Jam0864

  • Contributor
  • Fanatic
  • **
  • Posts: 744
    • MSN Messenger - marmalade0864@hotmail.com
    • View Profile
    • Jam0864's Content Dump
    • Email
Re: Maze generator
« Reply #5 on: 2007-03-24, 03:50:44 PM »
How would you put a function at each point? Do you have a sprite that it collides with at each point or something?

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: Maze generator
« Reply #6 on: 2007-03-25, 09:14:11 AM »
Does the follow path random points pick a different one every time it is run?  I thought it was a predictable random generator.

I think you're right (and I was kind of remembering that after I posted the message last time, but thought there would be a way around it) -- it will pick the same "random" sequence every time, unless some randomize function is called, and I'm doubting that the randomize function in VBScript would affect the random number generator in the compiled GDPlay engine.  So if you want to do this without scripting, you might have to create yet another map with a 3 point path where all 3 points are in the same location and have a sprite that follows random points on that path.   That will cause some random numbers to be generated as quickly as possible.  While it's doing that, wait for the player to finish doing something, like getting through a quick little initial level.  By the time the player finishes the little level, the random number generator should be at a reasonably un-predictable point, so you can move to the real random stuff.

How would you put a function at each point? Do you have a sprite that it collides with at each point or something?

Haven't you ever used the map editor to place a Special Function on the map?

Jam0864

  • Contributor
  • Fanatic
  • **
  • Posts: 744
    • MSN Messenger - marmalade0864@hotmail.com
    • View Profile
    • Jam0864's Content Dump
    • Email
Re: Maze generator
« Reply #7 on: 2007-03-26, 12:08:55 AM »
Oh, for some reason I didn't think of that. Probably because I don't really use it often. Or maybe I wasn't registering that this sprite with random points was the player sprite.
      Anyway. when changing sprites to go to the 50-point circular path, wouldn't the new sprites path be reset to the first point? Therefore no longer random.

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: Maze generator
« Reply #8 on: 2007-03-26, 06:06:21 AM »
The purpose of the first random sprite is to just get the random number generator to a "random" point.  Then when the next random sprite picks a random point (all random numbers come from the same random number generator) it won't be as predictable.  Yes the second sprite will start at its first point, but when it picks a random number to see what point to go to next, it will ask the "randomized" random number generator, and get a better (less predictable) result.

Jam0864

  • Contributor
  • Fanatic
  • **
  • Posts: 744
    • MSN Messenger - marmalade0864@hotmail.com
    • View Profile
    • Jam0864's Content Dump
    • Email
Re: Maze generator
« Reply #9 on: 2007-03-26, 04:07:38 PM »
cool, that should work then.   :)