Log In  

Cart #59148 | 2018-11-18 | Code ▽ | Embed ▽ | No License
3

This is much along the same lines as Gembit's remarkable game, "Eternal Tower" HERE:

https://www.lexaloffle.com/bbs/?tid=32173

and Polyphonic's random map generator HERE:

https://www.lexaloffle.com/bbs/?tid=32237

I've always wanted to write the code to a cavern maker where literally each wall is randomly placed and then checked to ensure that the areas around it can be reached.

And now you can ! Guarantees that all points can be reached despite the placement of the walls.

Change DEBUG in beginning to:
0 = Only draw completion
1 = Show the walls being drawn (default)
2 = Show the scanning process for each wall

Running into a bug, let me leave the stairs off for now. Should still run fine.
Got it fixed, should be alright now.

The randomly placed stairs leading up and down are considered FLOOR. That is, if you touch them, you can decide to take them or not. If I try to treat them as walls, they can get stuck in other walls.

Now my question is, can someone optimize this code so it runs considerably faster ?

Thanks, and enjoy !

P#59134 2018-11-18 12:37 ( Edited 2018-11-18 19:19)

Can you please don't insert spaces before the exclamation or question mark symbols?

Where did you get your English knowledge from?

P#64257 2019-05-09 12:15
1

Nice job, it's working nicely. You could also add a distance condition for the stairs because they occasionaly end up a few tiles away.

How did you manage to ensure the path is always walkable? I tried to dig in the code but I'm having hard time to figure out what's going on...

P#119604 2022-10-26 15:44
2

@StinkerB06, as a native English speaker, I'd suggest the politeness of the words we use is more important than an individual's use of punctuation marks...

P#119606 2022-10-26 16:04
1

Hi @aced.

Thank you ! I really do appreciate that.

I try to be courteous, especially when others are. The truth of the matter is I put a space before ! and ? much as Spanish has a ¡ ¿ before a sentence. So they can be seen.

I can glance quickly at a sentence before I start reading it and many times I cannot see the ! or ?

So then I reach the end of the sentence, reading out loud or in my head, and by then my inflection was in error, reading it as if it were just a flat statement.

Giving it a space at least for me makes it more visible and I am sure to recognize the sentence being one written in excitement or query before I even start to read the first word of that sentence - thereby giving it the proper elocution.

It also gives me a bit of a signature. I can scan most text rapidly and if I find a space before the ? or ! then chances are it is something I have written.

There are other subtle strange rules I follow to make my writing more visible to others but you'll have to discover those on your own. :)

P#119607 2022-10-26 16:22 ( Edited 2022-10-26 17:00)

Hi @pck404.

Thanks for your interest !

Yes, the code is probably not very readable. Sorry 'bout that.

The main reason I am in Pico-8 today is because you can code two ways. One of which is standard using function _update() and end()

And the other is to make use of goto and flip()

I'm an old-timer here and while I'll use _update() when attempting to make code legible for others, oftentimes I'll revert to my old ways and use goto and flip() instead.

With that said I am using the flip() method of coding above.

Essentially I am dropping a single tile in a random location that does not yet have a block.

Then I find another random location that also does not have a block and 'paint' outward from there a FLAG to look for. I keep looping until the 'paint' method has exhausted itself.

From there I scan to see if there is any tile that is neither wall nor FLAG. If there is, clearly the block I dropped is preventing you access to the entire map, and I remove it and try a different location.

After 110 iterations of not finding an opening my program is satisfied you have a suitable 'cavern' looking room and finishes.

I often write code like this, expecting a random value to create something I want, and if it doesn't, remove it, back up one step and try again.

This makes for small yet effective code but sometimes slow results overall.

P#119608 2022-10-26 16:57 ( Edited 2022-10-26 17:06)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-29 06:44:36 | 0.054s | Q:26