Skip to content

Commit

Permalink
Island.xml
Browse files Browse the repository at this point in the history
  • Loading branch information
mxgmn committed Jun 22, 2022
1 parent 213b3f1 commit af6cd78
Show file tree
Hide file tree
Showing 10 changed files with 239 additions and 60 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ obj/
*.user

output/
source/old/
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ Sources of examples:
1. [SokobanLevel1](models/SokobanLevel1.xml) seems to be the first level from Hiroyuki Imabayashi's Sokoban puzzle. [SokobanLevel2](models/SokobanLevel2.xml) is the [level 452](https://www.sokobanonline.com/play/web-archive/razorflame/ionic-catalysts-xi/58022_ionic-catalysts-xi-452) from Ionic Catalysts XI set.
1. [RainbowGrowth](models/RainbowGrowth.xml) was [proposed](https://github.com/mxgmn/MarkovJunior/discussions/25) by [mure](https://github.com/mure).
1. [MultiHeadedWalk](models/MultiHeadedWalk.xml), [MultiHeadedDungeon](models/MultiHeadedDungeon.xml) and [MultiHeadedWalkDungeon](models/MultiHeadedWalkDungeon.xml) are [based](https://github.com/mxgmn/MarkovJunior/discussions/38) on the idea by [Ilya Kudritsky](https://github.com/Inferdy).
1. [Island](models/Island.xml) model is by [Guillaume Fiette](https://github.com/woldendans/MJ-simple-island).

Voxel scenes were rendered in [MagicaVoxel](https://ephtracy.github.io/) by [ephtracy](https://github.com/ephtracy). Special thanks to [Brian Bucklew](https://github.com/unormal) for demonstrating the power of Dijkstra fields to me in roguelike level generation and [Kevin Chapelier](https://github.com/kchapelier) for a number of good suggestions. The font used in GUI is [Tamzen](https://github.com/sunaku/tamzen-font).

Expand Down
10 changes: 10 additions & 0 deletions models.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@
<model name="ModernHouse" length="9" width="9" height="4" iso="True"/>
<model name="SeaVilla" length="10" width="10" height="4" amount="4"/>
<model name="SeaVilla" length="10" width="10" height="4" iso="True"/>
<model name="Island" size="800" steps="-1" pixelsize="1">
<color symbol="I" value="abcbe8" comment="sea"/>
<color symbol="U" value="cee6f9" comment="coast and lakes"/>
<color symbol="T" value="2b8aa9" comment="rivers"/>
<color symbol="Y" value="f1ebc2" comment="sand"/>
<color symbol="G" value="a8d1a5" comment="grass"/>
<color symbol="E" value="93c08d" comment="forest"/>
<color symbol="S" value="d0d8ac" comment="slopes"/>
<color symbol="s" value="e9e0b2" comment="hills"/>
</model>

<model name="Backtracker" size="89"/>
<model name="BacktrackerCycle" size="59"/>
Expand Down
155 changes: 155 additions & 0 deletions models/Island.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
<sequence values="UWBRGEYINSOTus" origin="True">
<prl in="***/*U*/***" out="***/*Y*/***"/>

<one in="WY" out="WW" steps="1" comment="draw an island skeleton"/>
<one in="YWY/YYY" out="YWY/YWY" steps="400" comment="steps define the lenght of the backbone"/>
<one in="YWY/YWY/YYY" out="YWY/YRY/YYY" />
<one in="YYY/WWW" out="YWY/WWW" steps="20" comment="adjust steps to change number of branches. More branches = rounder, smoother island with less inner water"/>
<one in="YWY/YYY" out="YWY/YWY" steps="2300" comment="adjust steps for the length of branches. More lenght = bigger island"/>
<all in="R" out="W" />

<prl in="Y" out="U" p="0.00003" steps="1" comment="adjust p to reduce lakes"/>

<one comment="Voronoi">
<rule in="WY" out="WW"/>
<rule in="UY" out="UU"/>
</one>
<convolution neighborhood="Moore" comment="smoothing">
<rule in="U" out="W" sum="5..8" values="W"/>
<rule in="W" out="U" sum="5..8" values="U"/>
</convolution>

<all in="U/*" out="I/*" symmetry="(x)" comment="paint ocean to find out coasts. Sea will be U, lakes I, deep ocean B"/>
<all in="UI" out="UU"/>
<all in="WU" out="WR"/>
<prl in="RU" out="RR" steps="30" p="0.5" comment="steps = size of the shallow water around the coast"/>
<prl in="U" out="B"/>
<prl in="R" out="U"/>

<all in="UW" out="UG" comment="spawn a few river sources (paint coast green on some thickness to force sources to be inland)"/>
<all in="GW" out="GG" steps="80" comment="increase steps to push sources back from the sea"/>
<prl in="WW" out="WI" p="0.000015" steps="1" comment="play with p to change the number of sources"/>
<all in="G" out="W"/>

<sequence>
<one in="IW" out="IR" steps="1">
<field for="R" from="U" on="W"/>
</one>
<one>
<rule in="RU" out="NU"/>
<rule in="RO" out="NO"/>
<rule in="NNNRW/WWWWW" out="NNWWW/WWNNR" comment="break long, straight lines" />
<rule in="RW" out="NR" />

<observe value="W" to="WN"/>
<observe value="R" to="N"/>
</one>

<all in="N" out="O" comment="color done (O) so that we can merge rivers"/>
<all in="OI" out="OO" />
</sequence>

<prl steps="2" p="0.8" comment="widen the connection with the sea">
<rule in="UO/UW" out="UO/UO" />
<rule in="UO/WW" out="UO/OO" />
</prl>
<convolution neighborhood="Moore" periodic="True" comment="smooth">
<rule in="W" out="O" sum="6..8" values="O"/>
</convolution>

<prl in="WU" out="YU" steps="1" p="0.005" comment="generate beaches starting points"/>
<all steps="30" comment="march them along the coast">
<rule in="UU/YW" out="UU/YY" />
<rule in="UW/YW" out="UY/YY" />
</all>
<prl in="WY" out="YY" steps="3" p="0.4" comment="widen them with a bit of randomness"/>
<convolution neighborhood="Moore" periodic="True" comment="smooth them">
<rule in="Y" out="W" sum="5..8" values="W"/>
<rule in="W" out="Y" sum="5..8" values="Y"/>
</convolution>

<all in="O" out="u" comment="lakes and rivers back to lake blue"/>
<all in="UY" out="TY" />
<all in="UW" out="TW" />
<all in="uW" out="TW" />
<convolution neighborhood="Moore" periodic="True">
<rule in="U" out="T" sum="5..8" values="T"/>
<rule in="u" out="T" sum="5..8" values="T"/>
</convolution>

<prl in="UTW" out="UTG" p="0.1" steps="1" comment="seed forests and plains"/>
<prl in="YW" out="YG" p="1" steps="1" />
<prl in="WTW" out="WTE" p="0.05" steps="1" />
<prl in="W" out="G" p="0.00001" steps="1" />

<one comment="grow them, forest 3x stronger">
<rule in="WE" out="EE" />
<rule in="WE" out="EE" />
<rule in="WE" out="EE" />
<rule in="WG" out="GG" />
</one>

<convolution neighborhood="Moore" periodic="True">
<rule in="G" out="E" sum="5..8" values="E"/>
<rule in="E" out="G" sum="6..8" values="O"/>
</convolution>
<all in="W" out="G" comment="if any white, it's grass (islands). TODO: Eliminate islands next to lakes or islands too small"/>
<all in="B" out="I" comment="change deep ocean color"/>
<convolution neighborhood="Moore" periodic="True">
<rule in="U" out="I" sum="5..8" values="I"/>
<rule in="I" out="U" sum="5..8" values="U"/>
</convolution>

<all in="GE" out="GR" comment="let's grow mountains"/>
<all in="TE" out="TR" />
<prl in="E" out="S" p="0.0001" steps="1" />
<one>
<rule in="RE" out="RR" />
<rule in="SE" out="SS" />
<rule in="SE" out="SS" />
</one>
<all in="R" out="E" />
<convolution neighborhood="Moore" periodic="True">
<rule in="E" out="S" sum="5..8" values="S"/>
<rule in="S" out="E" sum="5..8" values="E"/>
</convolution>

<all in="ES" out="ER" />
<prl in="S" out="s" p="0.0002" steps="1" />
<one>
<rule in="RS" out="RR" />
<rule in="RS" out="RR" />
<rule in="RS" out="RR" />
<rule in="sS" out="ss" />
<rule in="sS" out="ss" />
<rule in="sS" out="ss" />
<rule in="sS" out="ss" />
</one>
<all in="R" out="S" />
<convolution neighborhood="Moore" periodic="True">
<rule in="S" out="s" sum="5..8" values="s"/>
<rule in="s" out="S" sum="5..8" values="S"/>
</convolution>

<sequence comment="final step, trace back rivers to mountains">
<one in="EEE/ETE" out="EEE/ERE" steps="1" />
<one>
<rule in="RS" out="NS" />
<rule in="RO" out="NO" />
<rule in="NNNRE/EEEEE" out="NNEEE/EENNR" comment="break long, straight lines" />
<rule in="RE" out="NR" />

<observe value="E" to="EN"/>
<observe value="R" to="N"/>
</one>

<one in="NS" out="RN" steps="5" />
<all in="R" out="T" />
<all in="N" out="T" />
</sequence>
<prl in="u" out="U"/>
</sequence>

<!--
Made by Guillaume Fiette https://github.com/woldendans/MJ-simple-island
-->
4 changes: 2 additions & 2 deletions models/MultiHeadedWalk.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<markov values="BRGW" origin="True">
<sequence values="BRGW" origin="True">
<sequence>
<one in="RB" out="*G" steps="3"/>
<all in="R" out="W"/>
<all in="G" out="R"/>
</sequence>
</markov>
</sequence>
104 changes: 52 additions & 52 deletions resources/palette.xml
Original file line number Diff line number Diff line change
@@ -1,56 +1,56 @@
<colors>
<color symbol="B" value="000000" rgb="0 0 0" name="Black"/>
<color symbol="I" value="1D2B53" rgb="29 43 83" name="Indigo"/>
<color symbol="P" value="7E2553" rgb="126 37 83" name="Purple"/>
<color symbol="E" value="008751" rgb="0 135 81" name="Emerald"/>
<color symbol="N" value="AB5236" rgb="171 82 54" name="browN"/>
<color symbol="D" value="5F574F" rgb="95 87 79" name="Dead"/>
<color symbol="A" value="C2C3C7" rgb="194 195 199" name="Alive"/>
<color symbol="W" value="FFF1E8" rgb="255 241 232" name="White"/>
<color symbol="R" value="FF004D" rgb="255 0 77" name="Red"/>
<color symbol="O" value="FFA300" rgb="255 163 0" name="Orange"/>
<color symbol="Y" value="FFEC27" rgb="255 236 39" name="Yellow"/>
<color symbol="G" value="00E436" rgb="0 228 54" name="Green"/>
<color symbol="U" value="29ADFF" rgb="41 173 255" name="blUe"/>
<color symbol="S" value="83769C" rgb="131 118 156" name="Slate"/>
<color symbol="K" value="FF77A8" rgb="255 119 168" name="pinK"/>
<color symbol="F" value="FFCCAA" rgb="255 204 170" name="Fawn"/>
<color symbol="B" value="000000" comment="Black"/>
<color symbol="I" value="1D2B53" comment="Indigo"/>
<color symbol="P" value="7E2553" comment="Purple"/>
<color symbol="E" value="008751" comment="Emerald"/>
<color symbol="N" value="AB5236" comment="browN"/>
<color symbol="D" value="5F574F" comment="Dead, Dark"/>
<color symbol="A" value="C2C3C7" comment="Alive, grAy"/>
<color symbol="W" value="FFF1E8" comment="White"/>
<color symbol="R" value="FF004D" comment="Red"/>
<color symbol="O" value="FFA300" comment="Orange"/>
<color symbol="Y" value="FFEC27" comment="Yellow"/>
<color symbol="G" value="00E436" comment="Green"/>
<color symbol="U" value="29ADFF" comment="blUe"/>
<color symbol="S" value="83769C" comment="Slate"/>
<color symbol="K" value="FF77A8" comment="pinK"/>
<color symbol="F" value="FFCCAA" comment="Fawn"/>

<color symbol="b" value="291814" rgb="41 24 20" name="black"/>
<color symbol="i" value="111d35" rgb="17 29 53" name="indigo"/>
<color symbol="p" value="422136" rgb="66 33 54" name="purple"/>
<color symbol="e" value="125359" rgb="18 83 89" name="emerald"/>
<color symbol="n" value="742f29" rgb="116 47 41" name="brown"/>
<color symbol="d" value="49333b" rgb="73 51 59" name="dead"/>
<color symbol="a" value="a28879" rgb="162 136 121" name="alive"/>
<color symbol="w" value="f3ef7d" rgb="243 239 125" name="white"/>
<color symbol="r" value="be1250" rgb="190 18 80" name="red"/>
<color symbol="o" value="ff6c24" rgb="255 108 36" name="orange"/>
<color symbol="y" value="a8e72e" rgb="168 231 46" name="yellow"/>
<color symbol="g" value="00b543" rgb="0 181 67" name="green"/>
<color symbol="u" value="065ab5" rgb="6 90 181" name="blue"/>
<color symbol="s" value="754665" rgb="117 70 101" name="slate"/>
<color symbol="k" value="ff6e59" rgb="255 110 89" name="pink"/>
<color symbol="f" value="ff9d81" rgb="255 157 129" name="fawn"/>
<color symbol="b" value="291814" comment="black"/>
<color symbol="i" value="111d35" comment="indigo"/>
<color symbol="p" value="422136" comment="purple"/>
<color symbol="e" value="125359" comment="emerald"/>
<color symbol="n" value="742f29" comment="brown"/>
<color symbol="d" value="49333b" comment="dead, dark"/>
<color symbol="a" value="a28879" comment="alive, gray"/>
<color symbol="w" value="f3ef7d" comment="white"/>
<color symbol="r" value="be1250" comment="red"/>
<color symbol="o" value="ff6c24" comment="orange"/>
<color symbol="y" value="a8e72e" comment="yellow"/>
<color symbol="g" value="00b543" comment="green"/>
<color symbol="u" value="065ab5" comment="blue"/>
<color symbol="s" value="754665" comment="slate"/>
<color symbol="k" value="ff6e59" comment="pink"/>
<color symbol="f" value="ff9d81" comment="fawn"/>

<color symbol="C" value="00ffff" rgb="0 255 255" name="Cyan"/>
<color symbol="c" value="5fcde4" rgb="95 205 228" name="cyan"/>
<color symbol="H" value="e4bb40" rgb="228 187 64" name="Honey"/>
<color symbol="h" value="8a6f30" rgb="138 111 48" name="honey"/>
<color symbol="J" value="4b692f" rgb="75 105 47" name="Jungle"/>
<color symbol="j" value="45107e" rgb="69 16 126" name="jungle"/>
<color symbol="L" value="847e87" rgb="132 126 135" name="Light"/>
<color symbol="l" value="696a6a" rgb="105 106 106" name="light"/>
<color symbol="M" value="ff00ff" rgb="255 0 255" name="Magenta"/>
<color symbol="m" value="9c09cc" rgb="156 9 204" name="magenta"/>
<color symbol="Q" value="9badb7" rgb="155 173 183" name="aQua"/>
<color symbol="q" value="3f3f74" rgb="63 63 116" name="aqua"/>
<color symbol="T" value="37946e" rgb="55 148 110" name="Teal"/>
<color symbol="t" value="323c39" rgb="50 60 57" name="teal"/>
<color symbol="V" value="8f974a" rgb="143 151 74" name="oliVe"/>
<color symbol="v" value="524b24" rgb="82 75 36" name="olive"/>
<color symbol="X" value="ff0000" rgb="255 0 0" name="X"/>
<color symbol="x" value="d95763" rgb="217 87 99" name="x"/>
<color symbol="Z" value="ffffff" rgb="255 255 255" name="Z"/>
<color symbol="z" value="cbdbfc" rgb="203 219 252" name="z"/>
<color symbol="C" value="00ffff" comment="Cyan"/>
<color symbol="c" value="5fcde4" comment="cyan"/>
<color symbol="H" value="e4bb40" comment="Honey"/>
<color symbol="h" value="8a6f30" comment="honey"/>
<color symbol="J" value="4b692f" comment="Jungle"/>
<color symbol="j" value="45107e" comment="jungle"/>
<color symbol="L" value="847e87" comment="Light"/>
<color symbol="l" value="696a6a" comment="light"/>
<color symbol="M" value="ff00ff" comment="Magenta"/>
<color symbol="m" value="9c09cc" comment="magenta"/>
<color symbol="Q" value="9badb7" comment="aQua"/>
<color symbol="q" value="3f3f74" comment="aqua"/>
<color symbol="T" value="37946e" comment="Teal"/>
<color symbol="t" value="323c39" comment="teal"/>
<color symbol="V" value="8f974a" comment="oliVe"/>
<color symbol="v" value="524b24" comment="olive"/>
<color symbol="X" value="ff0000" comment="X"/>
<color symbol="x" value="d95763" comment="x"/>
<color symbol="Z" value="ffffff" comment="Z"/>
<color symbol="z" value="cbdbfc" comment="z"/>
</colors>
2 changes: 1 addition & 1 deletion source/Map.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ override protected bool Load(XElement xelem, bool[] parentSymmetry, Grid grid)
(NY, DY) = readScale(scales[1]);
(NZ, DZ) = readScale(scales[2]);

newgrid = Grid.Load(xelem, NX * grid.MX / DX, NY * grid.MY / DY, NZ * grid.MZ / DZ);
newgrid = Grid.Load(xelem, grid.MX * NX / DX, grid.MY * NY / DY, grid.MZ * NZ / DZ);
if (newgrid == null) return false;

if (!base.Load(xelem, parentSymmetry, newgrid)) return false;
Expand Down
7 changes: 5 additions & 2 deletions source/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,20 @@ static void Main()
int gui = xmodel.Get("gui", 0);
if (gif) amount = 1;

Dictionary<char, int> customPalette = new(palette);
foreach (var x in xmodel.Elements("color")) customPalette[x.Get<char>("symbol")] = (255 << 24) + Convert.ToInt32(x.Get<string>("value"), 16);

for (int k = 0; k < amount; k++)
{
int seed = seeds != null && k < seeds.Length ? seeds[k] : meta.Next();
foreach ((byte[] result, char[] legend, int FX, int FY, int FZ) in interpreter.Run(seed, steps, gif))
{
int[] colors = legend.Select(ch => palette[ch]).ToArray();
int[] colors = legend.Select(ch => customPalette[ch]).ToArray();
string outputname = gif ? $"output/{interpreter.counter}" : $"output/{name}_{seed}";
if (FZ == 1 || iso)
{
var (bitmap, WIDTH, HEIGHT) = Graphics.Render(result, FX, FY, FZ, colors, pixelsize, gui);
if (gui > 0) GUI.Draw(name, interpreter.root, interpreter.current, bitmap, WIDTH, HEIGHT, palette);
if (gui > 0) GUI.Draw(name, interpreter.root, interpreter.current, bitmap, WIDTH, HEIGHT, customPalette);
Graphics.SaveBitmap(bitmap, WIDTH, HEIGHT, outputname + ".png");
}
else VoxHelper.SaveVox(result, (byte)FX, (byte)FY, (byte)FZ, colors, outputname + ".vox");
Expand Down
11 changes: 10 additions & 1 deletion source/RuleNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,16 @@ override protected bool Load(XElement xelem, bool[] parentSymmetry, Grid grid)
if (xfields.Any())
{
fields = new Field[grid.C];
foreach (XElement xfield in xfields) fields[grid.values[xfield.Get<char>("for")]] = new Field(xfield, grid);
foreach (XElement xfield in xfields)
{
char c = xfield.Get<char>("for");
if (grid.values.TryGetValue(c, out byte value)) fields[value] = new Field(xfield, grid);
else
{
Interpreter.WriteLine($"unknown field value {c} at line {xfield.LineNumber()}");
return false;
}
}
potentials = AH.Array2D(grid.C, grid.state.Length, 0);
}

Expand Down
Loading

0 comments on commit af6cd78

Please sign in to comment.