-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|596|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
SoCoder -> Snippet Home -> Generators

Pakz Created : 10 January 2022
Edited : 10 January 2022
Language : Lua (codea)

### Recursive map generator ## Latest Update

In a book I got last week there was a chapter on how great! Recursive functions are. One thing I learned from the book is called a Base Case. This is that logic part that exits a recursive function and stops it from calling itself again. This when a counter has gotten to low or a coordinate is outside of a region.

This code here is a sort of maze like map generator. Simply drawing vertical and horizontal lines in a random walk style method. Every line the end coordinates are stored and these wil be used to sometimes start a new line from(crossways)

The setmap function return false if there was a rule broken. Rules like outside map or to many walkable terrain on and around the current placement(this causes it to not go over itself)

The code is short but uncommented. Lua and typed on the ipad.

Monday, 10 January 2022, 02:19
rockford I like that. Clean and clear. Nice Monday, 10 January 2022, 04:06
Jayenkai Cool.
I do like making maze generators. There's TONS of ways you can do it, and at the end of the day it's just how you use it that makes it good or bad. Every maze style seems to create a vastly different game as a result, and it can be a great starting point for making a unique kind of game.

Do you have any games in mind for this one? Monday, 10 January 2022, 04:41
Pakz I just wanted to test out this recursive method of doing it. I also made another generator and added/copied out a wall tracer from a game ai book.

I have been thinking of what kind of ai to put in my current project. I was thinking of drawing a space snail or/and a walking machine that patrols the inside tunnels of a big asteroid/planetoid. But I want to read more in the new design books I gotten over the last weeks first. 