Custom Map #98: Toeval. By: Lost in Nowhere

Started by AutoPost, January 16, 2014, 06:55:16 PM

Previous topic - Next topic

AutoPost

This topic is for discussion of map #98: Toeval


Author: Lost in Nowhere
Size: 100x100

Desc:
An ordinary-looking world, with two decently strong emitters and faster-flowing creeper #CRPLGenerated

pawel345


Lost in Nowhere

Using a script that goes through, randomly placing circles with varying values (RandomTerrain.crpl), and then used a smoothing script (Smooth.crpl). I have no idea where the large craters came from, though...
Code (RandomTerrain.crpl) Select
#Author: Lost in Nowhere

$MinEffect:-0.5
$MaxEffect:1.5
$MinRadius:5
$MaxRadius:20
$Default:5.0
$Iterations:150

$Seed:12345

once
<-Seed ->randSeed
0 ->row
0 ->count

MapWidth 0 do
MapHeight 0 do
<-Default asfloat "x" I concat "y" J concat concat ->!
loop
loop
endonce

<-count <-Iterations lt if
0 MapWidth @RandIntRange ->xc
0 MapHeight @RandIntRange ->yc
<-MinEffect <-MaxEffect @RandFloatRange ->t
<-MinRadius <-MaxRadius @RandIntRange ->r
<-yc <-r add 1 add <-yc <-r sub do
<-xc <-r add 1 add <-xc <-r sub do
I J <-xc <-yc Distance <-r lte if
I J <-t @AddTerrain
endif
loop
loop
<-count 1 add ->count
else
<-row MapHeight lt if
MapWidth 0 do
I <-row dup2 @GetTerrain SetTerrain
loop
<-row 1 add ->row
endif
endif

:AddTerrain # x y t --
->atT ->atY ->atX
<-atX 0 gte and (<-atX MapWidth lt) and (<-atY 0 gte and (<-atY MapHeight lt)) if
"x" <-atX concat "y" <-atY concat concat ->atS
<-atS <-! <-atT add <-atS ->!
endif

:GetTerrain # x y -- i
->gtY ->gtX
"x" <-gtX concat "y" <-gtY concat concat <-! 0 Round

:RandFloat
<-randSeed mul (7204987) mod (2147483647) ->randSeed
<-randSeed abs 2147483647.0 div

:RandFloatRange
->rimax ->rimin
<-randSeed mul (7204987) mod (2147483647) ->randSeed
<-randSeed abs 2147483647.0 div <-rimax <-rimin sub mul <-rimin add

:RandIntRange
->rimax ->rimin
<-randSeed mul (7204987) mod (2147483647) ->randSeed
<-randSeed abs 2147483647.0 div <-rimax <-rimin sub mul <-rimin add floor

Code (Smooth.crpl) Select
# Smooth.crpl
# Created on: 12/29/2013 2:17:06 PM
# Author: Lost in Nowhere
# ------------------------------------------

$Passes:3
$Radius:2
$DefaultTerrain:1

once
0 ->pass
-1 ->row
endonce

<-pass <-Passes lt if
<-row 0 lt if
MapHeight 0 do
MapWidth 0 do
I J GetTerrain "X" I concat "Y" J concat concat ->!
loop
loop
else
<-row MapHeight lt if
MapWidth 0 do
I <-row I <-row @AverageNearTerrain SetTerrain
loop
else
<-pass 1 add ->pass
-2 ->row
endif
endif
<-row 1 add ->row
endif

:GetOldTerr
->gotY ->gotX
"X" <-gotX concat "Y" <-gotY concat concat dup -?! if <-! else pop <-DefaultTerrain endif

:AverageNearTerrain
->antY ->antX
0 0
1 <-Radius add <-Radius neg do
1 <-Radius add <-Radius neg do
swap <-antX I add <-antY J add @GetOldTerr add swap 1 add
loop
loop
div 0 Round

I've used the smooth script in practically every map I've made after the script. It's very useful.
Don't die! :)

adeilt

Ever get the feeling that you're forgetting to do something?  Something important?  Like you walked into a room and can't remember why?

Ah, well.  I'm sure I'll eventually remember what it was I was supposed to do.  Until then, I'll just bask in the glow of my reactors...