Jump to content
mendonca

Random Mapzoid: Random Bitmap Terrain Generator (Python / Win Exe)

Recommended Posts

Random Mapzoid: UNFORTUNATE SUBTITLE v0.60
  
mM8yRCd.png
 
Mapzoid is a little utility provided for the purposes of generating arbitrary, organic looking BMP files to use as the input for the WorldEd BMPtoTMX feature. It works alongside EasyPickins' Mapping Tools, hopefully fairly well.
 
It's currently in a fairly workable state, but I would appreciate some feedback, bug reports and general feature requests that anybody can think of. I'm personally not exactly swimming in spare time, but I will do what I can to fix any bugs or anything that may be raised.
 
The Python Code, or Windows Executable Package, can be found in the links below.
 
SOURCE (Python 2.7)
EXECUTABLE
 
SOURCE NOTES:

Spoiler


The source files should allow you to run this on Linux machines, although you will need to download the relevant libtcod.so from http://doryen.eptalys.net/libtcod/download/ for libtcod 1.5.0 (sorry that I'm using an older version   :oops: )
 
If you want to run from source you will also need the following Python Libraries:
 
Numpy http://www.numpy.org
Scipy http://www.scipy.org
Python Imaging Library http://www.pythonware.com/products/pil/
 
in addition to Libtcod.


 
Current Change List:
 

Spoiler


v0.20
 
- Town Algorithm Changed. Works a little better.
- Minor and Major Grids shifted out a little.
- Towns can now be generated in a world with but a single region.
- Some data externalised, in a text file called init.cfg, keyed to the Program variable name. Allows tweaking of certain things when compiled.
- Can now set file names.
- Can now set a seed. Believed to be deterministic (for noise at least).
- Add noise function changed to work more gentler-er on 2nd / 3rd / 4th uses. 1st still makes a large random mess.
- Support for non-square island maps.
 
v0.30
 
- Fixed crash with non-square maps, and towns
- Fixed some other bugs that came up
- Zoom and Overview preview maps. WSAD and Arrow keys to scroll.
- Externalised a lot more data - generalised the approach to graphics types. Can now use own rules for contour lines, colours, map references etc. by editing the init.cfg file. Not very well laid out at the minute, but it can be done. (needs a better parsing system, really).
- Fixed up the region preview mode, of a fashion.
 
v0.50
 
- Fixed scroll crash error when first starting and map size > 300
- More error handling (none of it detailed)
- Added TRUNK ROAD function
- Separated streets from the map data - can now preview and clear before 'committing'.
- Toggle the display of streets. Now show up in all modes.
- Re-ordered UI arrangement slightly
- JSON output for setup.cfg - a deal more readable by non-mechanical sentients
- Rewrote Readme and setup_about.cfg to give a little more help beyond the tooltips
- Outputs PNG file as well as BMP
 
v0.51
 
- bug where you can't ESC from town selection, scrolling keys buffers and all sorts of weirdness. Now right click to cancel, it makes a little bit more sense (I think). Can now scroll map whilst selecting position.
- Tidied up the levels on the JSON outputs so they are in order
- Removed redundant and commented out code from source script to tidy it up a bit
- Now draws in 'urban regions' and pavements. Width of pavements, and colours for all regions (picks random from a list) and pavements defined in setup.cfg.
- Fixed some more 'non-square' bugs associated with mixing up map_height and map_width occasionally in the script.
- Added 'Invert Heightmap' option
- Added 'Dress Roads' function. Adds smattering of textures around roads, texture and pattern defined in setup.cfg
- UI tidied up and re-ordered slightly again.
- Added help.txt tutorial
 
v0.60
 
- Help text updated
- Disassociated graphics and colour schemes from init data to help generally with 'modding' values
- Included weird example_gfx colour scheme - to overwrite if necessary
- Externalised autotown size and density modifiers for experimentation if required
- Externalised street_no_veg modifier around streets and allowed general whole numbers to be used


 
Read the readme.txt for some instructions on how to work the program, or just ask here.

 

Alternatively check out the following youtube video:

 


 
rWSaPC2.png
 
EXAMPLE OUTPUT:

 

Spoiler

UjaXdGk.png

 

9bKdpyi.png

 


 
IN WORLDED:

Spoiler

GAA71TI.png


 
This program is released open source under a permissive BSD license. Contributions or wholesale rip-offs are more than welcome, if you should so desire to join in.

Edited by mendonca

Share this post


Link to post
Share on other sites

Hey, I figured out how to use the program and its awesome!  That said, I can't figure out how to scroll around and view the map in the generator.  Once I get in into WorldEd its fine and I can use that to check it out, but using WASD and the arrow keys to view the map in the generator doesn't work for me at all.  It even caused it to crash once (because I got frusterated trying to figure it out and was pushing the arrow keys to quickly, I think).

Share this post


Link to post
Share on other sites

Hmmm ... I haven't had that problem myself.

 

Have you generated a map greater than 1 cell x 1 cell? Have you added something to the map so that you can actually tell that it is scrolling?

 

Are you in 'overview' mode? Overview gives a general overview of the whole map in the preview pane, there is no chance to scroll as each side of the map is the very edge of that particular map.

 

'Zoomed' mode gives a 1 cell x 1 cell preview in the view box - and it's not a pixel by pixel account of the map, more like a 10x zoom / general summary of the map. Works okay at default settings to show general noise pattern and most roads, but doesn't identify each pixel.

 

Also WSAD is case sensitive, something that I should possibly change - but it will currently only accept little letters as input.

 

Also I guess its possible that if you hit too many keys too fast it will struggle, but again I haven't been able to recreate this problem - and if I understand correctly the keypresses should be buffered or ignored, so I'm not sure if something else isn't going on ...

 

Sorry if these are a bit obvious, but they are my best thoughts at the moment!

 

Also out of interest are you running the .exe or from the Python script? Did any pop-up box appear when it crashed elaborating on why?

 

edit: Also you can't scroll if the program is 'thinking' - generating roads / noise, filling in zones or dressing the pavements etc. You'll have to wait for the particular process to finish (reported in the little text display at the bottom)

Share this post


Link to post
Share on other sites

Very nice program!

Im guessing with proper prefab buildings (or segments even) it would be possible to populate the towns as well?

 

Yeah, it would!

 

I think it would be fairly straightforward to add a button that assigns buildings to the sub-zoned regions built as part of the 'pave the world' function.

 

However, I never got round to figuring out the way the files read in all the relevant information for the world / building lots etc. so I never even tried to get it working.

 

Fancy a crack at it?  :-D

Share this post


Link to post
Share on other sites

Mendoca, I figured out the problem...and I feel like an idiot for it, but just in case any one else has the same issue, here it is:  I was holding the WASD keys (like you would in a game to scroll) instead of just pressing them and waiting half a second for the image to scroll.  It works fine when you press them properly.  I'm sorry about that.

Share this post


Link to post
Share on other sites

So can I edit the output Image and it should be fine before I add it to TileZed?

Oh yeah, this is to be encouraged. There's nothing special about the .png files that this program generates.

Just make sure you use VERY SPECIFIC colours, don't blend things, don't jpeg-> png or anything like that.

Basically colours need to exactly match those in the bmp->tmx rules.

Share this post


Link to post
Share on other sites

Two questions:

1. Can you suggest any good tutorials for packaging python programs as executables?

2. Why did you use a library for making rougelike games as your GUI instead of Tkinter which comes with python?

Sorry about the delay, I missed this question previously.  :oops: 

1. No. It is a ***** nightmare, I can't even remember how this thing works (the script I have set up to package this works, and that's all I can tell you about it). I'm not saying that to be difficult, I'm just saying that I struggled to understand what I was doing when I was doing it - and it was very hit and miss for me to get py2exe to reliably work (I might have even 'frigged' some of the dependencies in the Python standard library to actually make it work, if I recall correctly).

2. Familiarity - personally I do not know what tkinter is - or what it does. On the other hand I have spent a long time messing with libtcod, and can reasonably quickly carry out the sorts of tasks I want to do.

Share this post


Link to post
Share on other sites

Sorry for the delay in response ... I seem to still have not figured out this forum when I visit (and now it's changed again .. ha!) ... I didn't realise this thread had a couple of extra replies.

 

On 04/12/2015 at 6:52 PM, Jab said:

Why did you do this in Python 2? Preference? 

 

I feel like I may actually attempt to do something like this, with the actual save file format if I ever get the spark of the moment for PZ again. :) 

 

Good job though. 

Thanks!

 

Python 2 was a bit of a non-choice as that's pretty much all I can (could) do, including the use of Libtcod as the library. Basically toyed about a few years back with making a sort-of-roguelike, got used to the various bits, and then in a fit of inspiration created this one week whilst I was getting paid by my work to do something else entirely unrelated ...

Share this post


Link to post
Share on other sites
2 hours ago, mendonca said:

Sorry for the delay in response ... I seem to still have not figured out this forum when I visit (and now it's changed again .. ha!) ... I didn't realise this thread had a couple of extra replies.

 

Thanks!

 

Python 2 was a bit of a non-choice as that's pretty much all I can (could) do, including the use of Libtcod as the library. Basically toyed about a few years back with making a sort-of-roguelike, got used to the various bits, and then in a fit of inspiration created this one week whilst I was getting paid by my work to do something else entirely unrelated ...

 

Lucky getting paid to work on something unrelated (Sounds like Google). That's cool. My preference from Python 3 came from Blender's move from 2.4x to 2.5x series with an upgrade to Python 3.

Share this post


Link to post
Share on other sites

Hi Happyteacup;

 

Apologies but I'm not really up to speed with the current processes of getting a functional Worlded map implemented in to the game.

 

I'd suggest heading on over to the general map modding section where more specific - and current - advice would be better sought.

 

Sorry I can't be more help, and thanks for your interest in this little program :)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...