A good idea, but for a beginner?

Started by
7 comments, last by pjwaffle 15 years, 8 months ago
Hi, I want to make a open source TEXT-BASED RPG in Python... I want to start out pretty simple and work my way up! Here is what I want to be unique about it: Procedural Generation! I want to randomly generate the world to reduce art efforts (I am no artist, at least I can't draw :P )... I think such a technique would reduce time and effort spent on the game. Link to procedural generation on wikipedia: http://en.wikipedia.org/wiki/Procedural_generation
Advertisement
I think that doing the entire RPG might be a bit much for a beginner, but you could break it down into smaller projects - think of them as 'prototypes' for the full RPG - and they'd be manageable.

For example, you could write a program that, when run, generates a random room description. It's a great opportunity to look into procedural content methods like L-systems, and then you can start exploring ways of making neighboring rooms related to each other (instead of each one being a completely separate and random style, light level, etc).

Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse

Exactly what I was thinking... But what kind of algorithm can generate an entire room? My question is, how do you develop formulas/algorithms (At my age I have not learned how yet!)

EDIT: Thanks for the quick reply!
Well, imagine you're writing a guide for somebody else on how to methodically come up with the description of a room.


  1. First, say how big the room is, and how light/dark it is.

  2. Say what the walls, floor, and ceiling are made from. Leave them out if they're not interesting.

  3. Say whether there are doors/windows in the room, and what they are like.

  4. Say what furniture is in the room, and whereabouts it is.



"The room is big and bright, with wooden floorboards and plastered walls painted lilac. One large window is on the wall; the window is closed. In the corner of the room is a small wooden table."

That numbered list is an example of a simple algorithm designed to be carried out by a person. You could translate the same algorithm into something designed to be carried out by a computer by translating it into a programming language - and you'd likely need to break it down into simpler steps too, like "choose a random number; if it = 1 then roomSize = 'big' else roomSize = 'small';" and so on.

Of course, that algorithm would lead to some fairly dull and repetitive room descriptions; it also could lead to problems by, say, picking garden furniture for an indoor room. You could use an approach like L-Systems to 'grow' a room using a basic grammar - if the room contains a table, it should contain matching chairs, etc.

You could also experiment with rearranging the order in which you say things - maybe if you were to describe two things that are the same colour one after another, you can link them more effectively ("the cream walls blend smoothly into the large hearth") or create contrasts ("the green vase stands out against the red walls"); you could also try organising things such that your description 'sweeps' across the room in some path, e.g. furniture described in left-to-right order, and things in/on furniture described with the furniture ("a large cabinet adorns the left wall; on it a small lamp sits. At the back of the room hangs a portrait of the late Baron Skifflepuss."). There are many different techniques you can experiement with, but for the most part you find them by considering the patterns one can find in descriptions of rooms.

Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse

Thanks!

EDIT: How would the random number generator work?
Using the 'random' module.

Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse

Well here is my [sloppy] code with my own pprng (psuedo-pseudo-random-number-generator) it is a newbie's code, and it also a bunch of bugs I am sure but it is at least a start... oh well, better use the random module!
http://pastebin.com/m3eabf37e
You can generate "perfect" labyrinths, that is, labyrinths with exactly one path from any given staring point to any other point, by using this algorithm:

  1. Mark all the tiles in the grid as unexplored.
  2. Put walls up between all tiles in the grid.
  3. Start somewhere (any tile will do).
  4. For each direction (North, East, South, West) in random order that leads to an adjacent unexplored tile:

    • Knock down the wall between this tile and the unexplored tile.
    • Mark the unexplored tile as explored and move to it.
    • Perform step 4 recursively with the new starting point.

Technically it's a kind of randomized depth-first walk. The bold words are very important. Make sure you perform all of the bullet points before looking at the next direction. The easiest way to implement the algorithm is with recursion. You can use shuffle in the random module to randomize the directions.

When the algorithm stops, you have the maze. You can knock down more walls, insert doors, treasures and monsters at will, and get a pretty decent map.

EDIT: Whoops, are you talking about a sentence controlled game? I mean one where you write "go east", "examine foobar", etc? Then my answer is not that relevant, I'm sorry.

[Edited by - Ahnfelt on July 29, 2008 12:31:11 PM]
That's OK! I think it was still helpful in some way. Maybe I could include that in the base engine... which could then have many different clients and servers coded.

This topic is closed to new replies.

Advertisement