Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am looking to create a text-based map in which a player could (hypothetically) move through out infinitely. I was thinking I could do this through class objects defining towns / dungeons / etc. and placing them randomly through out the world. I was hoping this to be tile based, and for the tiles to have specific properties, i.e. water, dirt, grass, forest, town, dungeon, etc.

How could I go about doing this in Python 2.7?

share|improve this question
    
I think you're going to have trouble getting decent answers as formulated, because there are probably quite a few different approaches that can accomplish what you mention, using Python. Are you starting from scratch, or attempting to work with some text-based-game project that already exists in Python? – abathur Feb 1 '16 at 14:53

I agree with @abathur's comment, and a little more information would assist, but I've a few points that can provide a fair answer that you'll need to apply for yourself.

I've three sections: how you could think about the problem, some general implementation ideas and one area that should help refine the map to make it a bit more realistic seeming.

  1. One way to consider the problem: It seems plausible to use a generative map approach with a pseudo random process to determine your map tiles' features and properties (possibly using a fixed seed, if you need the map to be consistent between games/players). Not sure if you're aware, but the game Elite in the 80s took this approach, sidestepping the need to store all their planet data. It's worth googling, but some details are here: http://wiki.alioth.net/index.php/Random_number_generator

  2. Implementing: So ideally you'd need an idea of the tile features and properties you want. Write a handful of functions that take a number and turn that into a property from a cyclic group of options. The trick then is to turn any map coordinate into a number in a sequence as if it were on a chess board, eg row 2 column 3 might correspond to item 11. You plug that into a PRNG to get your random number out for that tile and then feed it into your feature functions and you've got a set of data for your map. The obvious limitation here as that the chess board (or bigger) still has a finite width. When the player reaches the edge you could then repeat the process but applying a multiple to the sequence number before it's feed in to obtain your random numbers. that multiple would correspond to that position in the bigger grid (of chess boards). I suspect there are other ways to come up with a sequence number that aren't bound by the board but I haven't any to hand.

  3. Improvements: You can have a look at the map as you go, but it's likely that a truly random map will look a bit unrealistic. One area to investigate is Perlin Noise. It's used to provide noise that appears to be "natural". The Wikipedia page is a good start and there's an article here which gives some ideas. http://devmag.org.za/2009/04/25/perlin-noise/ The main difference is that you're not going to be directly drawing the noise but using it for your features.

I hope this at least gives you some areas to think about. I'd be interested to hear what you end up doing!

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.