Share your repls and programming experiences

← Back to all posts
Terrain/Land Generation Algorithms with Map
PYer (3454)

Hey guys! It's been a long time since I've opened up repl.it and done some coding. (I took a break over the summer, my latest post being HyperTyper) So many new things. Teams, and the discord community has grown so much. @Coder100 got 2K cycles and passed me...

This is a project I started before the summer and have finished today. If you can remember, @DynamicSquid developed a simple terrain generation algorithm. I was inspired by this project, and added a few features.

#1) I created an HTML, CSS, JS repl in order to make it easier to read the map.

#2) After creating a random algorithm and recreating Squid's classic one, I decided it wasn't enough. I went through and added a couple more.

ALGORITHMS:

1 (a_random): Iterates over every tile selecting water or land with a 50/50 chance.

2 (a_classic): Iterates over every tile selecting water or land. Then repeats over the map 4 times, checking if a water tile is surrounded by 4+ land tiles. If True, the water tile becomes a land tile.

3 (a_rivers): Iterates over every tile, with a 1/50 chance of a water tile. Repeats over the map 2 times finding the water tiles. Tries to build a water tile above, to the right, left, or below. (In order of attempts).

4 (a_islands):

OKKKKKKKKKKKK... These are starting to get a little complicated. If you are curious look at the source code in the repl. I'm going to skip these.

If you want to toggle an animation, regenerating a new map every 1 second, click the animate button. Regenerating manually press regenerate. Don't get offended at my stylesheet, that's not the point of the page.

If you create another one, I might add it. Make sure it's in JS and follows the same structure as the other functions.

Thanks, and have fun expirementing!

PS: Comment your favorite algorithm!

Commentshotnewtop
potatojs (801)

wow your now are 10times more than me lol
@Coder100

DJWang (1231)

@Coder100 Congrats on almost 5000 upvotes! You deserve it after countless hours of hard work.

codeitfast (41)

@potatojs LOL. I've got, like, 10 chat numbers, so that is basically saying nothing XD

Leroy01010 (246)

yayayaayayayayaayayayayay

hi @PYer

My fave is a_sideview
also this is awesome

PYer (3454)

Hello, and thank you! @Leroy01010

JosephSanthosh (1181)

WHat in the world is this
?

sojs (246)

It is land generator. Made to generate landscapes, the landscapes that @pyer has done are rivers, random - randomly generating every tile - landscape, Islands and a side view You can use this to create maps in games without a canvas. @JosephSanthosh

JosephSanthosh (1181)

@sojs What? Well it's great to know @PYer is back!

CodeLongAndPros (1354)

Idea:
a_game_of_life:
Starts with all water, places a R-pentomino in center (as land) and iterate for 2000 generations

CodeLongAndPros (1354)

@DynamicSquid Yes, though I might have to hang it up soon, I don't know.

DynamicSquid (3561)

@CodeLongAndPros oh. but how'd you become one in the first place?

CodeLongAndPros (1354)

@DynamicSquid TheDrone7 emailed me asking about it, and I apparently have:

a decent sense of judgement.

DynamicSquid (3561)

@CodeLongAndPros oh cool! well done. but your parents won't let you?

CodeLongAndPros (1354)

@DynamicSquid They don't want me to see NSFW stuff...

They're on the fence on it.

DynamicSquid (3561)

@CodeLongAndPros wait how does repl.it have nsfw stuff lol. but that really does suck... wish you could stay a mod! all my parents know is that their kid does cool stuff and makes games on the computer. they don't know anything about code lol

CodeLongAndPros (1354)

@DynamicSquid I may stay a mod, I still have an appeal, I can point to the bans list... I still have htop hope. (I can't believe I mistyped that.)

DynamicSquid (3561)

@CodeLongAndPros show your parents how you can reverse the polarity of the neutron flow to correct for the positron leak! and maybe they'll let you be a mod

CodeLongAndPros (1354)

@DynamicSquid If TFTS taught me one thing:
CYB (Cover your back). I can point to the entire ban history.

DynamicSquid (3561)

@CodeLongAndPros ah.. okay lol. so what can you do as a mod? what powers do you have and what can you see?

CodeLongAndPros (1354)

@DynamicSquid I can edit / delete, unlink (inodes?), set answers, shadow bans...

CodeLongAndPros (1354)

@DynamicSquid Yeah.
But the report button is where the reply button was...
(Source: Reported HahaYes, don't worry, I undid it, I think)

CodeLongAndPros (1354)

@DynamicSquid

We trust you have received the usual lecture from the local System Administrator. It usually boils down to these three things:

#1) Respect the privacy of others.

#2) Think before you type.

#3) With great power comes great responsibility.

DynamicSquid (3561)

@CodeLongAndPros so that's a yes? oh okay. well congrats on mod!

CodeLongAndPros (1354)

@DynamicSquid That's a no, and thanks.
Wait, I can't report myself? That's dumb...

DJWang (1231)

@DynamicSquid @amasad doesn't want to be banned and he won't be cause he the CEO of the whole community

firefish (510)

@CodeLongAndPros

> su -
Enter password for amasad:
$> replit --delete-account:amasad
Are you sure? (y/n) y
Deleting [#################] 100%
-bash: bash: command not found
firefish (510)

@CodeLongAndPros

> su -
Enter password for amasad:
$> replit --delete-account:amasad
Are you sure? (y/n) y
Deleting [#################] 100%
-bash: bash: command not found
firefish (510)

@CodeLongAndPros I guess that outage hit us hard

firefish (510)

@DynamicSquid Well... er you're lucky... because my parents were the ones that taught me coding lol

DynamicSquid (3561)

@firefish oh lol. I had to learn everything myself

firefish (510)

@DynamicSquid pf... well that's what I did after my Dad taught me python, and I went onto learn Visual Basic (myself), Then got so fed up with the awful syntax and switched to another .NET language: C# (myself).

CodeLongAndPros (1354)

@firefish I did C+ first, for an arduino, then Python, then D.

firefish (510)

@CodeLongAndPros

C+

actually true story: I used to think there was C, C++, and C+ and C#

CodeLongAndPros (1354)

@firefish Well, Arduino has a weird thing going where String, char[], and char* are all valid.

firefish (510)

@CodeLongAndPros how about char**? I wonder...

firefish (510)

@CodeLongAndPros Just a mess. Consistency down the plughole. (That's C++ in a nutshell)

octopyBot (263)

@PYer @DynamicSquid @Coder100 @dabs364 I feel like we should help coder get higher than enigma! I know I don't like cheats! come one lets do this!

PYer (3454)

hmmm... what about getting me above them both? @octopyBot

DynamicSquid (3561)

@PYer hmmm... what about getting me about all of them?

DynamicSquid (3561)

@octopyBot lol jk. upvoting someone just for the sake of giving them cycles in unfair and against the rules

octopyBot (263)

@dabs364 no diden't you see dysquids thingy?

octopyBot (263)

@dabs364 no his comment!

its against the rules!

dabs364 (272)

@octopyBot whats against the rules eh?

EHEHEH

octopyBot (263)

@dabs364 cycle farming for coder!

BobTheTomatoPie (1061)

this is really cringy to read lmao @octopyBot

aguy11 (119)

Really nice! I liked a_landscape the most, it makes it's more detailed and more natural.

PYer (3454)

thanks! I like that one and the side view. @aguy11

PYer (3454)

ThanksQ Which one was your favorite? @ZDev1

PYer (3454)

lol ok @ZDev1 fast response btw

ZDev1 (615)

@PYer lul
but it is cool!

octopyBot (263)

YAS! @PYer is back in black!

dabs364 (272)

@octopyBot lets help @PYer beat @Coder100 like he should!

Coder100 (8404)

uggh what's the big deal with all these cycle races

people just gotta admit I am number 1 @dabs364

Coder100 (8404)

he only has 100 or so cycles @dabs364

Coder100 (8404)

he's a high schooler and he is male living in germany. @dabs364

Coder100 (8404)

on discord he has told us these. @dabs364

PYer (3454)

Wdym? @dabs364 @Coder100 has created much better quality posts.

dabs364 (272)

@PYer o
i thought you wanted to take the lead again...

PYer (3454)

I do, but I just want you guys to know that @Coder100 is a great coder as well. Otherwise he wouldn't be ahead of me. Also, cycles are the main point of repl.it. I mean, sure the convey your popularity, and what the community thinks of your work, but they relate to your projects. Projects/coding are the most important part of repl.it. Thanks for your support though :) @dabs364

Coder100 (8404)

no, he didn't get 6k legit @octopyBot

Coder100 (8404)

he's an employee at repl.it, they were one day playing around with cycles and one day he got a lot the end @octopyBot

octopyBot (263)

@Coder100 wdym he didn't get 7K legit?

octopyBot (263)

@Coder100 OH nvm then you're on top

PYer (3454)

the cycles were just added to his account without him actually gathering the votes. look at the posts or comments, there's no way he got the votes. @octopyBot

octopyBot (263)

@PYer true, I've never seen him on any post!

octopyBot (263)

@PYer also 7K is almost unreal

PYer (3454)

exactly. he used to be a member of the repl.it team and so added a bunch of cycles to his profile. it didn't show up on the leaderboard, since the repl.it team has an unfair advantage over normal users. But now that enigma left, he's top. @octopyBot

octopyBot (263)

@PYer ohhhhhh darn. I hate cheats! albeit, the last repl he made was like 9 months ago!

Coder100 (8404)

lmao well now you know! @octopyBot

firefish (510)

@PYer I wouldn't agree with you, you make better things than the grilled cookie ever could

octopyBot (263)

@firefish grilled cookie is coder? oh right, his pfp looks like a burnt cookie

firefish (510)

@octopyBot Yes. He's grilled because we (me and @HahaYes) THOUGHT he destroyed our code, but he didn't, but he's had that name ever since.

firefish (510)

@octopyBot Sad story I know. But making a project about grilling cookies coming soon!

octopyBot (263)

@firefish haha looking forward to it!!

octopyBot (263)

@firefish lol u already leaked it right?

octopyBot (263)

@firefish wow this actually really rad

firefish (510)

@octopyBot there's no game there yet, just some useless text

octopyBot (263)

@firefish lol well the sign-in is awesome

firefish (510)

@octopybot read the footer, it says it been stolen quite clearly

DynamicSquid (3561)

@PYer what'd you do over the summer?

PYer (3454)

I took a road trip, visited a ranch, and went on a backpacking trip. I also had a trip to hawaii and one to florida canceled because of the coronavirus. I haven't coded over the summer the past 3 years I've used repl.it. I also didn't have a lot of internet connection and access to technology. @DynamicSquid

DynamicSquid (3561)

@PYer oh wow cool! sucks that your trip to florida and hawaii were canceled

PYer (3454)

Yeah, but I still had a lot of fun. Did you do anything interesting? @DynamicSquid

DynamicSquid (3561)

@PYer nope lol. just coding a lot

PYer (3454)

Nice. You've made a lot of cycles. @DynamicSquid

DynamicSquid (3561)

@PYer oh yea thx. i released a few good projects

PyCoder01 (41)

@PYer I want to change the discord bot's avatar (Py_Assist)

PyCoder01 (41)

@PYer I need you to debug Py_Assist there is a problem I debugged it

PyCoder01 (41)

@PYer I'm pyer01 changed my name

RobertFurr (46)

i was trying to work on something like this a while back with python and it looks like you beat me to it

clawstrike (16)

Dude, if it wasn't amazing, would upvote and comment @PYer? This was sick! I don't even think I could match to that👍👍👍😐😐😮😮😮

PYer (3454)

haha. i'm sure you could if you tried... @clawstrike

BobTheTomatoPie (1061)

this is awesome dude! I have an idea that could be cool, if you don't like it that's fine, but hear me out. There is a button that will pick from a random algorithm each time, so maybe one time it will be a river, and the next a set of islands

PYer (3454)

oooooooohhhh that's actually a good idea! @BobTheTomatoPie

SidS (0)

landscape animation was my favorite

AJDevelopment (50)

just wait until someone implements this in minecraft

firefish (510)

I made one called a.oceanic, I'll invite you now... (it's a 3/10 chance of land basically)

PYer (3454)

ill take a look at it! @firefish

firefish (510)

@PYer I'm adding something to it rn btw

python88 (161)

how many upvotes this has is how many people do this game 24/7

mkhoi (291)

Idea:
Maybe you can recreate my generation algorithm, here is it (also i don't know what to name it):
https://repl.it/@mkhoi/mountainous-terrain-on-space-rocks#main.py

sojs (246)

my fav is landscape, or side view

[deleted]

yay

sojs (246)

Very Nice. Clean look too.

PYer (3454)

Why thank you! @sojs It was more of a focus on the algorithms than the styling.