Skip to content

Commit af6cd78

Browse files
committed
Island.xml
1 parent 213b3f1 commit af6cd78

File tree

10 files changed

+239
-60
lines changed

10 files changed

+239
-60
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ obj/
88
*.user
99

1010
output/
11+
source/old/

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ Sources of examples:
221221
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.
222222
1. [RainbowGrowth](models/RainbowGrowth.xml) was [proposed](https://github.com/mxgmn/MarkovJunior/discussions/25) by [mure](https://github.com/mure).
223223
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).
224+
1. [Island](models/Island.xml) model is by [Guillaume Fiette](https://github.com/woldendans/MJ-simple-island).
224225

225226
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).
226227

models.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@
77
<model name="ModernHouse" length="9" width="9" height="4" iso="True"/>
88
<model name="SeaVilla" length="10" width="10" height="4" amount="4"/>
99
<model name="SeaVilla" length="10" width="10" height="4" iso="True"/>
10+
<model name="Island" size="800" steps="-1" pixelsize="1">
11+
<color symbol="I" value="abcbe8" comment="sea"/>
12+
<color symbol="U" value="cee6f9" comment="coast and lakes"/>
13+
<color symbol="T" value="2b8aa9" comment="rivers"/>
14+
<color symbol="Y" value="f1ebc2" comment="sand"/>
15+
<color symbol="G" value="a8d1a5" comment="grass"/>
16+
<color symbol="E" value="93c08d" comment="forest"/>
17+
<color symbol="S" value="d0d8ac" comment="slopes"/>
18+
<color symbol="s" value="e9e0b2" comment="hills"/>
19+
</model>
1020

1121
<model name="Backtracker" size="89"/>
1222
<model name="BacktrackerCycle" size="59"/>

models/Island.xml

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
<sequence values="UWBRGEYINSOTus" origin="True">
2+
<prl in="***/*U*/***" out="***/*Y*/***"/>
3+
4+
<one in="WY" out="WW" steps="1" comment="draw an island skeleton"/>
5+
<one in="YWY/YYY" out="YWY/YWY" steps="400" comment="steps define the lenght of the backbone"/>
6+
<one in="YWY/YWY/YYY" out="YWY/YRY/YYY" />
7+
<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"/>
8+
<one in="YWY/YYY" out="YWY/YWY" steps="2300" comment="adjust steps for the length of branches. More lenght = bigger island"/>
9+
<all in="R" out="W" />
10+
11+
<prl in="Y" out="U" p="0.00003" steps="1" comment="adjust p to reduce lakes"/>
12+
13+
<one comment="Voronoi">
14+
<rule in="WY" out="WW"/>
15+
<rule in="UY" out="UU"/>
16+
</one>
17+
<convolution neighborhood="Moore" comment="smoothing">
18+
<rule in="U" out="W" sum="5..8" values="W"/>
19+
<rule in="W" out="U" sum="5..8" values="U"/>
20+
</convolution>
21+
22+
<all in="U/*" out="I/*" symmetry="(x)" comment="paint ocean to find out coasts. Sea will be U, lakes I, deep ocean B"/>
23+
<all in="UI" out="UU"/>
24+
<all in="WU" out="WR"/>
25+
<prl in="RU" out="RR" steps="30" p="0.5" comment="steps = size of the shallow water around the coast"/>
26+
<prl in="U" out="B"/>
27+
<prl in="R" out="U"/>
28+
29+
<all in="UW" out="UG" comment="spawn a few river sources (paint coast green on some thickness to force sources to be inland)"/>
30+
<all in="GW" out="GG" steps="80" comment="increase steps to push sources back from the sea"/>
31+
<prl in="WW" out="WI" p="0.000015" steps="1" comment="play with p to change the number of sources"/>
32+
<all in="G" out="W"/>
33+
34+
<sequence>
35+
<one in="IW" out="IR" steps="1">
36+
<field for="R" from="U" on="W"/>
37+
</one>
38+
<one>
39+
<rule in="RU" out="NU"/>
40+
<rule in="RO" out="NO"/>
41+
<rule in="NNNRW/WWWWW" out="NNWWW/WWNNR" comment="break long, straight lines" />
42+
<rule in="RW" out="NR" />
43+
44+
<observe value="W" to="WN"/>
45+
<observe value="R" to="N"/>
46+
</one>
47+
48+
<all in="N" out="O" comment="color done (O) so that we can merge rivers"/>
49+
<all in="OI" out="OO" />
50+
</sequence>
51+
52+
<prl steps="2" p="0.8" comment="widen the connection with the sea">
53+
<rule in="UO/UW" out="UO/UO" />
54+
<rule in="UO/WW" out="UO/OO" />
55+
</prl>
56+
<convolution neighborhood="Moore" periodic="True" comment="smooth">
57+
<rule in="W" out="O" sum="6..8" values="O"/>
58+
</convolution>
59+
60+
<prl in="WU" out="YU" steps="1" p="0.005" comment="generate beaches starting points"/>
61+
<all steps="30" comment="march them along the coast">
62+
<rule in="UU/YW" out="UU/YY" />
63+
<rule in="UW/YW" out="UY/YY" />
64+
</all>
65+
<prl in="WY" out="YY" steps="3" p="0.4" comment="widen them with a bit of randomness"/>
66+
<convolution neighborhood="Moore" periodic="True" comment="smooth them">
67+
<rule in="Y" out="W" sum="5..8" values="W"/>
68+
<rule in="W" out="Y" sum="5..8" values="Y"/>
69+
</convolution>
70+
71+
<all in="O" out="u" comment="lakes and rivers back to lake blue"/>
72+
<all in="UY" out="TY" />
73+
<all in="UW" out="TW" />
74+
<all in="uW" out="TW" />
75+
<convolution neighborhood="Moore" periodic="True">
76+
<rule in="U" out="T" sum="5..8" values="T"/>
77+
<rule in="u" out="T" sum="5..8" values="T"/>
78+
</convolution>
79+
80+
<prl in="UTW" out="UTG" p="0.1" steps="1" comment="seed forests and plains"/>
81+
<prl in="YW" out="YG" p="1" steps="1" />
82+
<prl in="WTW" out="WTE" p="0.05" steps="1" />
83+
<prl in="W" out="G" p="0.00001" steps="1" />
84+
85+
<one comment="grow them, forest 3x stronger">
86+
<rule in="WE" out="EE" />
87+
<rule in="WE" out="EE" />
88+
<rule in="WE" out="EE" />
89+
<rule in="WG" out="GG" />
90+
</one>
91+
92+
<convolution neighborhood="Moore" periodic="True">
93+
<rule in="G" out="E" sum="5..8" values="E"/>
94+
<rule in="E" out="G" sum="6..8" values="O"/>
95+
</convolution>
96+
<all in="W" out="G" comment="if any white, it's grass (islands). TODO: Eliminate islands next to lakes or islands too small"/>
97+
<all in="B" out="I" comment="change deep ocean color"/>
98+
<convolution neighborhood="Moore" periodic="True">
99+
<rule in="U" out="I" sum="5..8" values="I"/>
100+
<rule in="I" out="U" sum="5..8" values="U"/>
101+
</convolution>
102+
103+
<all in="GE" out="GR" comment="let's grow mountains"/>
104+
<all in="TE" out="TR" />
105+
<prl in="E" out="S" p="0.0001" steps="1" />
106+
<one>
107+
<rule in="RE" out="RR" />
108+
<rule in="SE" out="SS" />
109+
<rule in="SE" out="SS" />
110+
</one>
111+
<all in="R" out="E" />
112+
<convolution neighborhood="Moore" periodic="True">
113+
<rule in="E" out="S" sum="5..8" values="S"/>
114+
<rule in="S" out="E" sum="5..8" values="E"/>
115+
</convolution>
116+
117+
<all in="ES" out="ER" />
118+
<prl in="S" out="s" p="0.0002" steps="1" />
119+
<one>
120+
<rule in="RS" out="RR" />
121+
<rule in="RS" out="RR" />
122+
<rule in="RS" out="RR" />
123+
<rule in="sS" out="ss" />
124+
<rule in="sS" out="ss" />
125+
<rule in="sS" out="ss" />
126+
<rule in="sS" out="ss" />
127+
</one>
128+
<all in="R" out="S" />
129+
<convolution neighborhood="Moore" periodic="True">
130+
<rule in="S" out="s" sum="5..8" values="s"/>
131+
<rule in="s" out="S" sum="5..8" values="S"/>
132+
</convolution>
133+
134+
<sequence comment="final step, trace back rivers to mountains">
135+
<one in="EEE/ETE" out="EEE/ERE" steps="1" />
136+
<one>
137+
<rule in="RS" out="NS" />
138+
<rule in="RO" out="NO" />
139+
<rule in="NNNRE/EEEEE" out="NNEEE/EENNR" comment="break long, straight lines" />
140+
<rule in="RE" out="NR" />
141+
142+
<observe value="E" to="EN"/>
143+
<observe value="R" to="N"/>
144+
</one>
145+
146+
<one in="NS" out="RN" steps="5" />
147+
<all in="R" out="T" />
148+
<all in="N" out="T" />
149+
</sequence>
150+
<prl in="u" out="U"/>
151+
</sequence>
152+
153+
<!--
154+
Made by Guillaume Fiette https://github.com/woldendans/MJ-simple-island
155+
-->

models/MultiHeadedWalk.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
<markov values="BRGW" origin="True">
1+
<sequence values="BRGW" origin="True">
22
<sequence>
33
<one in="RB" out="*G" steps="3"/>
44
<all in="R" out="W"/>
55
<all in="G" out="R"/>
66
</sequence>
7-
</markov>
7+
</sequence>

resources/palette.xml

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,56 @@
11
<colors>
2-
<color symbol="B" value="000000" rgb="0 0 0" name="Black"/>
3-
<color symbol="I" value="1D2B53" rgb="29 43 83" name="Indigo"/>
4-
<color symbol="P" value="7E2553" rgb="126 37 83" name="Purple"/>
5-
<color symbol="E" value="008751" rgb="0 135 81" name="Emerald"/>
6-
<color symbol="N" value="AB5236" rgb="171 82 54" name="browN"/>
7-
<color symbol="D" value="5F574F" rgb="95 87 79" name="Dead"/>
8-
<color symbol="A" value="C2C3C7" rgb="194 195 199" name="Alive"/>
9-
<color symbol="W" value="FFF1E8" rgb="255 241 232" name="White"/>
10-
<color symbol="R" value="FF004D" rgb="255 0 77" name="Red"/>
11-
<color symbol="O" value="FFA300" rgb="255 163 0" name="Orange"/>
12-
<color symbol="Y" value="FFEC27" rgb="255 236 39" name="Yellow"/>
13-
<color symbol="G" value="00E436" rgb="0 228 54" name="Green"/>
14-
<color symbol="U" value="29ADFF" rgb="41 173 255" name="blUe"/>
15-
<color symbol="S" value="83769C" rgb="131 118 156" name="Slate"/>
16-
<color symbol="K" value="FF77A8" rgb="255 119 168" name="pinK"/>
17-
<color symbol="F" value="FFCCAA" rgb="255 204 170" name="Fawn"/>
2+
<color symbol="B" value="000000" comment="Black"/>
3+
<color symbol="I" value="1D2B53" comment="Indigo"/>
4+
<color symbol="P" value="7E2553" comment="Purple"/>
5+
<color symbol="E" value="008751" comment="Emerald"/>
6+
<color symbol="N" value="AB5236" comment="browN"/>
7+
<color symbol="D" value="5F574F" comment="Dead, Dark"/>
8+
<color symbol="A" value="C2C3C7" comment="Alive, grAy"/>
9+
<color symbol="W" value="FFF1E8" comment="White"/>
10+
<color symbol="R" value="FF004D" comment="Red"/>
11+
<color symbol="O" value="FFA300" comment="Orange"/>
12+
<color symbol="Y" value="FFEC27" comment="Yellow"/>
13+
<color symbol="G" value="00E436" comment="Green"/>
14+
<color symbol="U" value="29ADFF" comment="blUe"/>
15+
<color symbol="S" value="83769C" comment="Slate"/>
16+
<color symbol="K" value="FF77A8" comment="pinK"/>
17+
<color symbol="F" value="FFCCAA" comment="Fawn"/>
1818

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

36-
<color symbol="C" value="00ffff" rgb="0 255 255" name="Cyan"/>
37-
<color symbol="c" value="5fcde4" rgb="95 205 228" name="cyan"/>
38-
<color symbol="H" value="e4bb40" rgb="228 187 64" name="Honey"/>
39-
<color symbol="h" value="8a6f30" rgb="138 111 48" name="honey"/>
40-
<color symbol="J" value="4b692f" rgb="75 105 47" name="Jungle"/>
41-
<color symbol="j" value="45107e" rgb="69 16 126" name="jungle"/>
42-
<color symbol="L" value="847e87" rgb="132 126 135" name="Light"/>
43-
<color symbol="l" value="696a6a" rgb="105 106 106" name="light"/>
44-
<color symbol="M" value="ff00ff" rgb="255 0 255" name="Magenta"/>
45-
<color symbol="m" value="9c09cc" rgb="156 9 204" name="magenta"/>
46-
<color symbol="Q" value="9badb7" rgb="155 173 183" name="aQua"/>
47-
<color symbol="q" value="3f3f74" rgb="63 63 116" name="aqua"/>
48-
<color symbol="T" value="37946e" rgb="55 148 110" name="Teal"/>
49-
<color symbol="t" value="323c39" rgb="50 60 57" name="teal"/>
50-
<color symbol="V" value="8f974a" rgb="143 151 74" name="oliVe"/>
51-
<color symbol="v" value="524b24" rgb="82 75 36" name="olive"/>
52-
<color symbol="X" value="ff0000" rgb="255 0 0" name="X"/>
53-
<color symbol="x" value="d95763" rgb="217 87 99" name="x"/>
54-
<color symbol="Z" value="ffffff" rgb="255 255 255" name="Z"/>
55-
<color symbol="z" value="cbdbfc" rgb="203 219 252" name="z"/>
36+
<color symbol="C" value="00ffff" comment="Cyan"/>
37+
<color symbol="c" value="5fcde4" comment="cyan"/>
38+
<color symbol="H" value="e4bb40" comment="Honey"/>
39+
<color symbol="h" value="8a6f30" comment="honey"/>
40+
<color symbol="J" value="4b692f" comment="Jungle"/>
41+
<color symbol="j" value="45107e" comment="jungle"/>
42+
<color symbol="L" value="847e87" comment="Light"/>
43+
<color symbol="l" value="696a6a" comment="light"/>
44+
<color symbol="M" value="ff00ff" comment="Magenta"/>
45+
<color symbol="m" value="9c09cc" comment="magenta"/>
46+
<color symbol="Q" value="9badb7" comment="aQua"/>
47+
<color symbol="q" value="3f3f74" comment="aqua"/>
48+
<color symbol="T" value="37946e" comment="Teal"/>
49+
<color symbol="t" value="323c39" comment="teal"/>
50+
<color symbol="V" value="8f974a" comment="oliVe"/>
51+
<color symbol="v" value="524b24" comment="olive"/>
52+
<color symbol="X" value="ff0000" comment="X"/>
53+
<color symbol="x" value="d95763" comment="x"/>
54+
<color symbol="Z" value="ffffff" comment="Z"/>
55+
<color symbol="z" value="cbdbfc" comment="z"/>
5656
</colors>

source/Map.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ override protected bool Load(XElement xelem, bool[] parentSymmetry, Grid grid)
3838
(NY, DY) = readScale(scales[1]);
3939
(NZ, DZ) = readScale(scales[2]);
4040

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

4444
if (!base.Load(xelem, parentSymmetry, newgrid)) return false;

source/Program.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,20 @@ static void Main()
5454
int gui = xmodel.Get("gui", 0);
5555
if (gif) amount = 1;
5656

57+
Dictionary<char, int> customPalette = new(palette);
58+
foreach (var x in xmodel.Elements("color")) customPalette[x.Get<char>("symbol")] = (255 << 24) + Convert.ToInt32(x.Get<string>("value"), 16);
59+
5760
for (int k = 0; k < amount; k++)
5861
{
5962
int seed = seeds != null && k < seeds.Length ? seeds[k] : meta.Next();
6063
foreach ((byte[] result, char[] legend, int FX, int FY, int FZ) in interpreter.Run(seed, steps, gif))
6164
{
62-
int[] colors = legend.Select(ch => palette[ch]).ToArray();
65+
int[] colors = legend.Select(ch => customPalette[ch]).ToArray();
6366
string outputname = gif ? $"output/{interpreter.counter}" : $"output/{name}_{seed}";
6467
if (FZ == 1 || iso)
6568
{
6669
var (bitmap, WIDTH, HEIGHT) = Graphics.Render(result, FX, FY, FZ, colors, pixelsize, gui);
67-
if (gui > 0) GUI.Draw(name, interpreter.root, interpreter.current, bitmap, WIDTH, HEIGHT, palette);
70+
if (gui > 0) GUI.Draw(name, interpreter.root, interpreter.current, bitmap, WIDTH, HEIGHT, customPalette);
6871
Graphics.SaveBitmap(bitmap, WIDTH, HEIGHT, outputname + ".png");
6972
}
7073
else VoxHelper.SaveVox(result, (byte)FX, (byte)FY, (byte)FZ, colors, outputname + ".vox");

source/RuleNode.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,16 @@ override protected bool Load(XElement xelem, bool[] parentSymmetry, Grid grid)
6666
if (xfields.Any())
6767
{
6868
fields = new Field[grid.C];
69-
foreach (XElement xfield in xfields) fields[grid.values[xfield.Get<char>("for")]] = new Field(xfield, grid);
69+
foreach (XElement xfield in xfields)
70+
{
71+
char c = xfield.Get<char>("for");
72+
if (grid.values.TryGetValue(c, out byte value)) fields[value] = new Field(xfield, grid);
73+
else
74+
{
75+
Interpreter.WriteLine($"unknown field value {c} at line {xfield.LineNumber()}");
76+
return false;
77+
}
78+
}
7079
potentials = AH.Array2D(grid.C, grid.state.Length, 0);
7180
}
7281

0 commit comments

Comments
 (0)