Board index » delphi » 2000 rooms

2000 rooms

I'm trying to make a program that has 2000 different rooms which a
person can enter. I want to link these rooms together so that...
  eg.  room 1353 can access room 34, 8, 2 ,793
the problem is, I want to be able to randomize these 2000 rooms
once in a while. I guess it's a lot like tw2002 the structure of it.
If anyone can get me kick started it would be a big help.

Thanks   Mannox

 

Re:2000 rooms


Quote
Michael Masters wrote:

> I'm trying to make a program that has 2000 different rooms which a
> person can enter. I want to link these rooms together so that...
>   eg.  room 1353 can access room 34, 8, 2 ,793
> the problem is, I want to be able to randomize these 2000 rooms
> once in a while. I guess it's a lot like tw2002 the structure of it.
> If anyone can get me kick started it would be a big help.

> Thanks   Mannox

     Are the number of neighboring rooms fixed?  If so, you could use an
array structure.  [Actually, a linked list has some appeal, but if you
want to randomize them, managing such a structure might be something of
a nightmare!].  You might create a record type something like the
following:

  CONST
   maxroomnumber = 2000;
   maxneighbors = 4;
  TYPE
   roomnumbertype = 1 .. maxroomnumber;
   neighborindextype = 1 .. maxneighbors;
   roomtype = RECORD
     thisroom : roomnumbertype;
     neighbors : ARRAY [neighborindextype] OF roomnumbertype
  END;

Something you could do if you want to use fewer than the maximum number
of neighbors is to have the neighbor point back to the room itself.
This suggests the following initialization routine:

  FOR roomnumber := 1 TO maxroomnumber DO
   WITH room[roomnumber] DO
    BEGIN
     thisroom := roomnumber;
     FOR neighborindex := 1 TO maxneighbors DO
     neighbors[neighborindex] := roomnumber;
    END;

This initializes all of your rooms as unconnected (actually, as
connected to themselves).  Now you can link them however you wish.

Bob Schor
Pascal Enthusiast

Re:2000 rooms


Re:2000 rooms


Quote
Michael Masters wrote:

> I'm trying to make a program that has 2000 different rooms which a
> person can enter. I want to link these rooms together so that...
>   eg.  room 1353 can access room 34, 8, 2 ,793
> the problem is, I want to be able to randomize these 2000 rooms
> once in a while. I guess it's a lot like tw2002 the structure of it.
> If anyone can get me kick started it would be a big help.

> Thanks   Mannox

If you're trying to program a text adventure, hop over to
news:rec.arts.in-fiction & check out the faq. There are at least 6 well
supported languages for defining 'dungeons', their connections, their
contents and ways of moving between them. Although a great Pascal fan myself,
I also recognize that one should use the tool best suited to the job.
Of course, if you don't know about these languages .... "when all you have
is a hammer, every problem looks like a nail".

On the other hand, if you're not programnming an adventure/role playing game,
please ignore the above  :-)

Re:2000 rooms


Re:2000 rooms


On 1 Nov 1996, Michael Masters wrote:

Quote
> I'm trying to make a program that has 2000 different rooms which a
> person can enter. I want to link these rooms together so that...
>   eg.  room 1353 can access room 34, 8, 2 ,793
> the problem is, I want to be able to randomize these 2000 rooms
> once in a while. I guess it's a lot like tw2002 the structure of it.
> If anyone can get me kick started it would be a big help.

> Thanks   Mannox

        Well I'm not sure exactly what you want to do, but here is a shot:

First do this:
const
   maxX = 500;
   maxY = 400;
Type
   arenatype = array[1..MaxX, 1..MaxY] of <RoomType>

Then create a record usertype which stores the users position in the
arena array :

   usertype = record
      x,y : integer;

Then if the user press up for example do this:
    user.y := user.y - 1;

which would move the user into the room above him (he is ambigous)
 ___________
|_|_|_|_|_|_|
|_|_|_|X|_|_|
|_|_|_|_|_|_|

If THe user is at X he can then move to the left right up or down rooms from
where he is.

use roomtype to display whatever you want to (so basically the arena
stores all the rooms and the user variable stores the users position in
the arena, and the screen displays whats in room).

Other Threads