From 53bbbd03fafcfbcb4f3a34c66577d25caab3a0e2 Mon Sep 17 00:00:00 2001 From: tobi Date: Thu, 25 Apr 2024 17:17:10 +0200 Subject: [PATCH 1/3] Add automapping prototype --- Cargo.toml | 3 + automap_test.map | Bin 0 -> 16361 bytes automapper/basic_freeze.rules | 597 ++++++++++++++++++++++++++++++++++ automapper/ddmax_freeze.rules | 197 +++++++++++ automapper/ddnet_tiles.rules | 74 +++++ automapper/ddnet_walls.rules | 424 ++++++++++++++++++++++++ src/bin/automap_test.rs | 15 + src/map.rs | 51 ++- 8 files changed, 1358 insertions(+), 3 deletions(-) create mode 100644 automap_test.map create mode 100644 automapper/basic_freeze.rules create mode 100644 automapper/ddmax_freeze.rules create mode 100644 automapper/ddnet_tiles.rules create mode 100644 automapper/ddnet_walls.rules create mode 100644 src/bin/automap_test.rs diff --git a/Cargo.toml b/Cargo.toml index 29dea0c..307573c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,6 +22,9 @@ name = "twmap_test" [[bin]] name = "ddnet_bridge" + +[[bin]] +name = "automap_test" # required-features = ["ddnet_bridge"] [dependencies] diff --git a/automap_test.map b/automap_test.map new file mode 100644 index 0000000000000000000000000000000000000000..f9375188e4afb9e82b42dfe9a4ba9db890327161 GIT binary patch literal 16361 zcmeHO30M=!wr^v?1!!54sDZRer@LNtfO#`_dEb58{qFZ3^?iq4s_H+d{yOJW zHQjMoxMpEL1VLVL5u~v%f((G?22j{zM;`>~w1FqxMGqc-FR&Wv5f+0L2!VV7MZf#H zKRgbG!uDeTf_w>&Y##v6hj!nG2i^Ut@VFGpE+}bGI-tyh9lfADg)$v>42L3uk_V*@ z3R_07!aVG9F#{H=#G z_AZOlC4a1E@3Ez)o`HHM4Hd@~=tf|* zn^9}ZfPYnUaZH1@E^}ibh{gxO?66?sEc#1ok;54x*pz5q<7afe-7SoRw$S($fwRQW zFna%>)g5SX+`Ss0hqyl+L=Jwm&yM(2of^0}HivGoeu^|dXhC3QV_!CL43)oT~lH%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(Q+k#XDChW_u zOcuHY6SG0fV?Y(j!}NYjV{miL-5~{SRClUz(ygNkNo)oII_WBY=x+%Q?zx?7lt9C@ zS+QI1>Q%bsRjf3VsnHP7Y3$yU`q*9l1(g;n0NuF?nyCu@@rk17%sb%03HkWBtdk09 zLXcZ4^Uu^OCr-u&b59%WO68r#H(|KZP$bm+C3WAHcm9+3!@JLgjHZe0;Ko6a{ddTH zK?M_<{NEIR{CS9~^y8H_QYk}_4`T=vUnP~Bm- z=W;_8i{$sJ3(3C^MA{CFoD^-$LC#}+)hjee+pM93$0LY#iwaHeD3Eit=Yri6Xe*s+ z5`HV$-2pz%ZLbCo%c=SBo0xBOZQ+NS?uTjK)cjQVbxDMW4!5`2zX~C16d>H0QNyX( z-~pas!Ek1#wDZ)L;k$nKFnS931Ru zA4a6Wq!86K!n)A*Ky0%DZ^OWRF03$4A=^5ce1=L@LLF&u{`r;Ah~Co6KraKm4D>S4 z%Rny!y$tj+(96KzWI*d2wAY^fZS2_hpiOuPJ|O+86>UGyK4}9Eh_-lr*2a4Lnhm}j zvf#^MqaHiI-ijy}&i>QVK5q}&2lqb;`hN5nE7bcl|C*M+#AmFw|0x6gsb0IjWeoa_ z9XE0a;-Y6d6{5J?!(ZPFL-g3w!lC^_BZfN&#{PNax#^ostk#&!8hS7kLB3jrY+~!j S4jFLw>@B?kNWXaG>wg2!_T`lT literal 0 HcmV?d00001 diff --git a/automapper/basic_freeze.rules b/automapper/basic_freeze.rules new file mode 100644 index 0000000..98fc94c --- /dev/null +++ b/automapper/basic_freeze.rules @@ -0,0 +1,597 @@ +[Freeze soft corners] + +Index 0 +Pos 0 0 NOTINDEX 3 OR 4 OR 19 OR 20 OR 52 OR 35 OR 36 OR 56 OR 57 OR 72 OR 73 OR 89 + +NewRun + +Index 4 + +Index 17 +Pos 0 0 EMPTY +Pos 0 -1 FULL +Pos 1 0 EMPTY +Pos 0 1 EMPTY +Pos -1 0 FULL +Pos 0 -1 NOTINDEX -1 +Pos -1 0 NOTINDEX -1 + +Index 17 ROTATE +Pos 0 0 EMPTY +Pos 0 -1 FULL +Pos 1 0 FULL +Pos 0 1 EMPTY +Pos -1 0 EMPTY +Pos 0 -1 NOTINDEX -1 +Pos 1 0 NOTINDEX -1 + +Index 17 XFLIP YFLIP +Pos 0 0 EMPTY +Pos 0 -1 EMPTY +Pos 1 0 FULL +Pos 0 1 FULL +Pos -1 0 EMPTY +Pos 1 0 NOTINDEX -1 +Pos 0 1 NOTINDEX -1 + +Index 17 ROTATE XFLIP YFLIP +Pos 0 0 EMPTY +Pos 0 -1 EMPTY +Pos 1 0 EMPTY +Pos 0 1 FULL +Pos -1 0 FULL +Pos 0 1 NOTINDEX -1 +Pos -1 0 NOTINDEX -1 + +Index 18 +Pos 0 0 EMPTY +Pos 0 -1 FULL +Pos 1 0 FULL +Pos 0 1 EMPTY +Pos -1 0 FULL + +Index 18 ROTATE +Pos 0 0 EMPTY +Pos 0 -1 FULL +Pos 1 0 FULL +Pos 0 1 FULL +Pos -1 0 EMPTY + +Index 18 XFLIP YFLIP +Pos 0 0 EMPTY +Pos 0 -1 EMPTY +Pos 1 0 FULL +Pos 0 1 FULL +Pos -1 0 FULL + +Index 18 ROTATE XFLIP YFLIP +Pos 0 0 EMPTY +Pos 0 -1 FULL +Pos 1 0 EMPTY +Pos 0 1 FULL +Pos -1 0 FULL + +Index 34 +Pos 0 0 EMPTY +Pos 0 -1 FULL +Pos 1 0 FULL +Pos 0 1 FULL +Pos -1 0 FULL + +Index 19 +Pos 0 -1 EMPTY +Pos -1 0 EMPTY +Pos -1 -1 EMPTY + +Index 19 ROTATE +Pos 0 -1 EMPTY +Pos 1 0 EMPTY +Pos 1 -1 EMPTY + +Index 19 XFLIP YFLIP +Pos 0 1 EMPTY +Pos 1 0 EMPTY +Pos 1 1 EMPTY + +Index 19 ROTATE XFLIP YFLIP +Pos 0 1 EMPTY +Pos -1 0 EMPTY +Pos -1 1 EMPTY + +Index 20 +Pos -1 0 EMPTY +Pos -1 -1 EMPTY +Pos 0 -1 EMPTY +Pos 1 -1 EMPTY +Pos 1 0 EMPTY + +Index 20 ROTATE +Pos 0 -1 EMPTY +Pos 1 -1 EMPTY +Pos 1 0 EMPTY +Pos 1 1 EMPTY +Pos 0 1 EMPTY + +Index 20 XFLIP YFLIP +Pos 1 0 EMPTY +Pos 1 1 EMPTY +Pos 0 1 EMPTY +Pos -1 1 EMPTY +Pos -1 0 EMPTY + +Index 20 ROTATE XFLIP YFLIP +Pos 0 -1 EMPTY +Pos -1 -1 EMPTY +Pos -1 0 EMPTY +Pos -1 1 EMPTY +Pos 0 1 EMPTY + +Index 52 +Pos 1 -1 FULL +Pos -1 1 FULL +Pos 1 0 EMPTY +Pos 1 1 EMPTY +Pos 0 1 EMPTY +Pos 0 -1 EMPTY +Pos -1 -1 EMPTY +Pos -1 0 EMPTY + +Index 52 ROTATE +Pos -1 -1 FULL +Pos 1 1 FULL +Pos 0 -1 EMPTY +Pos 1 -1 EMPTY +Pos 1 0 EMPTY +Pos -1 0 EMPTY +Pos -1 1 EMPTY +Pos 0 1 EMPTY + +Index 35 +Pos -1 1 FULL +Pos -1 -1 EMPTY +Pos 0 -1 EMPTY +Pos 1 -1 EMPTY +Pos 1 0 EMPTY +Pos 1 1 EMPTY +Pos 0 1 EMPTY +Pos -1 0 EMPTY + +Index 35 ROTATE +Pos -1 -1 FULL +Pos 0 -1 EMPTY +Pos 1 -1 EMPTY +Pos 1 0 EMPTY +Pos 1 1 EMPTY +Pos 0 1 EMPTY +Pos -1 1 EMPTY +Pos -1 0 EMPTY + +Index 35 XFLIP YFLIP +Pos 1 -1 FULL +Pos -1 -1 EMPTY +Pos 0 -1 EMPTY +Pos 1 0 EMPTY +Pos 1 1 EMPTY +Pos 0 1 EMPTY +Pos -1 1 EMPTY +Pos -1 0 EMPTY + +Index 35 ROTATE XFLIP YFLIP +Pos 1 1 FULL +Pos -1 -1 EMPTY +Pos 0 -1 EMPTY +Pos 1 -1 EMPTY +Pos 1 0 EMPTY +Pos 0 1 EMPTY +Pos -1 1 EMPTY +Pos -1 0 EMPTY + +Index 36 +Pos -1 -1 EMPTY +Pos 0 -1 EMPTY +Pos 1 -1 EMPTY +Pos 1 0 EMPTY +Pos 1 1 EMPTY +Pos 0 1 EMPTY +Pos -1 1 EMPTY +Pos -1 0 EMPTY + + + +[Freeze round corners] + +Index 0 +Pos 0 0 NOTINDEX 3 OR 4 OR 19 OR 20 OR 52 OR 35 OR 36 OR 56 OR 57 OR 72 OR 73 OR 89 + +NewRun + +Index 4 + +Index 17 +Pos 0 0 EMPTY +Pos 0 -1 FULL +Pos 1 0 EMPTY +Pos 0 1 EMPTY +Pos -1 0 FULL +Pos 0 -1 NOTINDEX -1 +Pos -1 0 NOTINDEX -1 + +Index 17 ROTATE +Pos 0 0 EMPTY +Pos 0 -1 FULL +Pos 1 0 FULL +Pos 0 1 EMPTY +Pos -1 0 EMPTY +Pos 0 -1 NOTINDEX -1 +Pos 1 0 NOTINDEX -1 + +Index 17 XFLIP YFLIP +Pos 0 0 EMPTY +Pos 0 -1 EMPTY +Pos 1 0 FULL +Pos 0 1 FULL +Pos -1 0 EMPTY +Pos 1 0 NOTINDEX -1 +Pos 0 1 NOTINDEX -1 + +Index 17 ROTATE XFLIP YFLIP +Pos 0 0 EMPTY +Pos 0 -1 EMPTY +Pos 1 0 EMPTY +Pos 0 1 FULL +Pos -1 0 FULL +Pos 0 1 NOTINDEX -1 +Pos -1 0 NOTINDEX -1 + +Index 18 +Pos 0 0 EMPTY +Pos 0 -1 FULL +Pos 1 0 FULL +Pos 0 1 EMPTY +Pos -1 0 FULL + +Index 18 ROTATE +Pos 0 0 EMPTY +Pos 0 -1 FULL +Pos 1 0 FULL +Pos 0 1 FULL +Pos -1 0 EMPTY + +Index 18 XFLIP YFLIP +Pos 0 0 EMPTY +Pos 0 -1 EMPTY +Pos 1 0 FULL +Pos 0 1 FULL +Pos -1 0 FULL + +Index 18 ROTATE XFLIP YFLIP +Pos 0 0 EMPTY +Pos 0 -1 FULL +Pos 1 0 EMPTY +Pos 0 1 FULL +Pos -1 0 FULL + +Index 34 +Pos 0 0 EMPTY +Pos 0 -1 FULL +Pos 1 0 FULL +Pos 0 1 FULL +Pos -1 0 FULL + +Index 3 +Pos 0 -1 EMPTY +Pos -1 0 EMPTY +Pos -1 -1 EMPTY + +Index 3 ROTATE +Pos 0 -1 EMPTY +Pos 1 0 EMPTY +Pos 1 -1 EMPTY + +Index 3 XFLIP YFLIP +Pos 0 1 EMPTY +Pos 1 0 EMPTY +Pos 1 1 EMPTY + +Index 3 ROTATE XFLIP YFLIP +Pos 0 1 EMPTY +Pos -1 0 EMPTY +Pos -1 1 EMPTY + +Index 20 +Pos -1 0 EMPTY +Pos -1 -1 EMPTY +Pos 0 -1 EMPTY +Pos 1 -1 EMPTY +Pos 1 0 EMPTY + +Index 20 ROTATE +Pos 0 -1 EMPTY +Pos 1 -1 EMPTY +Pos 1 0 EMPTY +Pos 1 1 EMPTY +Pos 0 1 EMPTY + +Index 20 XFLIP YFLIP +Pos 1 0 EMPTY +Pos 1 1 EMPTY +Pos 0 1 EMPTY +Pos -1 1 EMPTY +Pos -1 0 EMPTY + +Index 20 ROTATE XFLIP YFLIP +Pos 0 -1 EMPTY +Pos -1 -1 EMPTY +Pos -1 0 EMPTY +Pos -1 1 EMPTY +Pos 0 1 EMPTY + +Index 52 +Pos 1 -1 FULL +Pos -1 1 FULL +Pos 1 0 EMPTY +Pos 1 1 EMPTY +Pos 0 1 EMPTY +Pos 0 -1 EMPTY +Pos -1 -1 EMPTY +Pos -1 0 EMPTY + +Index 52 ROTATE +Pos -1 -1 FULL +Pos 1 1 FULL +Pos 0 -1 EMPTY +Pos 1 -1 EMPTY +Pos 1 0 EMPTY +Pos -1 0 EMPTY +Pos -1 1 EMPTY +Pos 0 1 EMPTY + +Index 35 +Pos -1 1 FULL +Pos -1 -1 EMPTY +Pos 0 -1 EMPTY +Pos 1 -1 EMPTY +Pos 1 0 EMPTY +Pos 1 1 EMPTY +Pos 0 1 EMPTY +Pos -1 0 EMPTY + +Index 35 ROTATE +Pos -1 -1 FULL +Pos 0 -1 EMPTY +Pos 1 -1 EMPTY +Pos 1 0 EMPTY +Pos 1 1 EMPTY +Pos 0 1 EMPTY +Pos -1 1 EMPTY +Pos -1 0 EMPTY + +Index 35 XFLIP YFLIP +Pos 1 -1 FULL +Pos -1 -1 EMPTY +Pos 0 -1 EMPTY +Pos 1 0 EMPTY +Pos 1 1 EMPTY +Pos 0 1 EMPTY +Pos -1 1 EMPTY +Pos -1 0 EMPTY + +Index 35 ROTATE XFLIP YFLIP +Pos 1 1 FULL +Pos -1 -1 EMPTY +Pos 0 -1 EMPTY +Pos 1 -1 EMPTY +Pos 1 0 EMPTY +Pos 0 1 EMPTY +Pos -1 1 EMPTY +Pos -1 0 EMPTY + +Index 36 +Pos -1 -1 EMPTY +Pos 0 -1 EMPTY +Pos 1 -1 EMPTY +Pos 1 0 EMPTY +Pos 1 1 EMPTY +Pos 0 1 EMPTY +Pos -1 1 EMPTY +Pos -1 0 EMPTY + + + +[Freeze diagonal corners] + +Index 0 +Pos 0 0 NOTINDEX 3 OR 4 OR 19 OR 20 OR 52 OR 35 OR 36 OR 56 OR 57 OR 72 OR 73 OR 89 + +NewRun + +Index 4 + +Index 54 +Pos 0 0 EMPTY +Pos 0 -1 FULL +Pos 1 0 EMPTY +Pos 0 1 EMPTY +Pos -1 0 FULL +Pos 0 -1 NOTINDEX -1 +Pos -1 0 NOTINDEX -1 + +Index 54 ROTATE +Pos 0 0 EMPTY +Pos 0 -1 FULL +Pos 1 0 FULL +Pos 0 1 EMPTY +Pos -1 0 EMPTY +Pos 0 -1 NOTINDEX -1 +Pos 1 0 NOTINDEX -1 + +Index 54 XFLIP YFLIP +Pos 0 0 EMPTY +Pos 0 -1 EMPTY +Pos 1 0 FULL +Pos 0 1 FULL +Pos -1 0 EMPTY +Pos 1 0 NOTINDEX -1 +Pos 0 1 NOTINDEX -1 + +Index 54 ROTATE XFLIP YFLIP +Pos 0 0 EMPTY +Pos 0 -1 EMPTY +Pos 1 0 EMPTY +Pos 0 1 FULL +Pos -1 0 FULL +Pos 0 1 NOTINDEX -1 +Pos -1 0 NOTINDEX -1 + +Index 55 +Pos 0 0 EMPTY +Pos 0 -1 FULL +Pos 1 0 FULL +Pos 0 1 EMPTY +Pos -1 0 FULL + +Index 55 ROTATE +Pos 0 0 EMPTY +Pos 0 -1 FULL +Pos 1 0 FULL +Pos 0 1 FULL +Pos -1 0 EMPTY + +Index 55 XFLIP YFLIP +Pos 0 0 EMPTY +Pos 0 -1 EMPTY +Pos 1 0 FULL +Pos 0 1 FULL +Pos -1 0 FULL + +Index 55 ROTATE XFLIP YFLIP +Pos 0 0 EMPTY +Pos 0 -1 FULL +Pos 1 0 EMPTY +Pos 0 1 FULL +Pos -1 0 FULL + +Index 87 +Pos 0 0 EMPTY +Pos 0 -1 FULL +Pos 1 0 FULL +Pos 0 1 FULL +Pos -1 0 FULL + +Index 56 +Pos 0 -1 EMPTY +Pos 1 0 EMPTY +Pos 1 -1 EMPTY + +Index 56 ROTATE +Pos 0 1 EMPTY +Pos 1 0 EMPTY +Pos 1 1 EMPTY + +Index 56 XFLIP YFLIP +Pos 0 1 EMPTY +Pos -1 0 EMPTY +Pos -1 1 EMPTY + +Index 56 ROTATE XFLIP YFLIP +Pos 0 -1 EMPTY +Pos -1 0 EMPTY +Pos -1 -1 EMPTY + +Index 57 +Pos -1 0 EMPTY +Pos -1 -1 EMPTY +Pos 0 -1 EMPTY +Pos 1 -1 EMPTY +Pos 1 0 EMPTY + +Index 57 ROTATE +Pos 0 -1 EMPTY +Pos 1 -1 EMPTY +Pos 1 0 EMPTY +Pos 1 1 EMPTY +Pos 0 1 EMPTY + +Index 57 XFLIP YFLIP +Pos 1 0 EMPTY +Pos 1 1 EMPTY +Pos 0 1 EMPTY +Pos -1 1 EMPTY +Pos -1 0 EMPTY + +Index 57 ROTATE XFLIP YFLIP +Pos 0 -1 EMPTY +Pos -1 -1 EMPTY +Pos -1 0 EMPTY +Pos -1 1 EMPTY +Pos 0 1 EMPTY + +Index 72 +Pos 1 -1 FULL +Pos -1 1 FULL +Pos 1 0 EMPTY +Pos 1 1 EMPTY +Pos 0 1 EMPTY +Pos 0 -1 EMPTY +Pos -1 -1 EMPTY +Pos -1 0 EMPTY + +Index 72 ROTATE +Pos -1 -1 FULL +Pos 1 1 FULL +Pos 0 -1 EMPTY +Pos 1 -1 EMPTY +Pos 1 0 EMPTY +Pos -1 0 EMPTY +Pos -1 1 EMPTY +Pos 0 1 EMPTY + +Index 73 +Pos -1 1 FULL +Pos -1 -1 EMPTY +Pos 0 -1 EMPTY +Pos 1 -1 EMPTY +Pos 1 0 EMPTY +Pos 1 1 EMPTY +Pos 0 1 EMPTY +Pos -1 0 EMPTY + +Index 73 ROTATE +Pos -1 -1 FULL +Pos 0 -1 EMPTY +Pos 1 -1 EMPTY +Pos 1 0 EMPTY +Pos 1 1 EMPTY +Pos 0 1 EMPTY +Pos -1 1 EMPTY +Pos -1 0 EMPTY + +Index 73 XFLIP YFLIP +Pos 1 -1 FULL +Pos -1 -1 EMPTY +Pos 0 -1 EMPTY +Pos 1 0 EMPTY +Pos 1 1 EMPTY +Pos 0 1 EMPTY +Pos -1 1 EMPTY +Pos -1 0 EMPTY + +Index 73 ROTATE XFLIP YFLIP +Pos 1 1 FULL +Pos -1 -1 EMPTY +Pos 0 -1 EMPTY +Pos 1 -1 EMPTY +Pos 1 0 EMPTY +Pos 0 1 EMPTY +Pos -1 1 EMPTY +Pos -1 0 EMPTY + +Index 89 +Pos -1 -1 EMPTY +Pos 0 -1 EMPTY +Pos 1 -1 EMPTY +Pos 1 0 EMPTY +Pos 1 1 EMPTY +Pos 0 1 EMPTY +Pos -1 1 EMPTY +Pos -1 0 EMPTY diff --git a/automapper/ddmax_freeze.rules b/automapper/ddmax_freeze.rules new file mode 100644 index 0000000..325728f --- /dev/null +++ b/automapper/ddmax_freeze.rules @@ -0,0 +1,197 @@ +[Freeze] + +Index 0 +Pos 0 0 NOTINDEX 1 OR 16 OR 17 OR 18 OR 19 OR 20 + +NewRun + +Index 1 + +Index 2 +Pos 0 0 EMPTY +Pos 0 -1 FULL +Pos 1 0 EMPTY +Pos 0 1 EMPTY +Pos -1 0 FULL +Pos 0 -1 NOTINDEX -1 +Pos -1 0 NOTINDEX -1 + +Index 2 ROTATE +Pos 0 0 EMPTY +Pos 0 -1 FULL +Pos 1 0 FULL +Pos 0 1 EMPTY +Pos -1 0 EMPTY +Pos 0 -1 NOTINDEX -1 +Pos 1 0 NOTINDEX -1 + +Index 2 XFLIP YFLIP +Pos 0 0 EMPTY +Pos 0 -1 EMPTY +Pos 1 0 FULL +Pos 0 1 FULL +Pos -1 0 EMPTY +Pos 1 0 NOTINDEX -1 +Pos 0 1 NOTINDEX -1 + +Index 2 ROTATE XFLIP YFLIP +Pos 0 0 EMPTY +Pos 0 -1 EMPTY +Pos 1 0 EMPTY +Pos 0 1 FULL +Pos -1 0 FULL +Pos 0 1 NOTINDEX -1 +Pos -1 0 NOTINDEX -1 + +Index 3 +Pos 0 0 EMPTY +Pos 0 -1 FULL +Pos 1 0 FULL +Pos 0 1 EMPTY +Pos -1 0 FULL + +Index 3 ROTATE +Pos 0 0 EMPTY +Pos 0 -1 FULL +Pos 1 0 FULL +Pos 0 1 FULL +Pos -1 0 EMPTY + +Index 3 XFLIP YFLIP +Pos 0 0 EMPTY +Pos 0 -1 EMPTY +Pos 1 0 FULL +Pos 0 1 FULL +Pos -1 0 FULL + +Index 3 ROTATE XFLIP YFLIP +Pos 0 0 EMPTY +Pos 0 -1 FULL +Pos 1 0 EMPTY +Pos 0 1 FULL +Pos -1 0 FULL + +Index 4 +Pos 0 0 EMPTY +Pos 0 -1 FULL +Pos 1 0 FULL +Pos 0 1 FULL +Pos -1 0 FULL + +Index 16 +Pos 0 -1 EMPTY +Pos -1 0 EMPTY +Pos -1 -1 EMPTY + +Index 16 ROTATE +Pos 0 -1 EMPTY +Pos 1 0 EMPTY +Pos 1 -1 EMPTY + +Index 16 XFLIP YFLIP +Pos 0 1 EMPTY +Pos 1 0 EMPTY +Pos 1 1 EMPTY + +Index 16 ROTATE XFLIP YFLIP +Pos 0 1 EMPTY +Pos -1 0 EMPTY +Pos -1 1 EMPTY + +Index 17 +Pos -1 0 EMPTY +Pos -1 -1 EMPTY +Pos 0 -1 EMPTY +Pos 1 -1 EMPTY +Pos 1 0 EMPTY + +Index 17 ROTATE +Pos 0 -1 EMPTY +Pos 1 -1 EMPTY +Pos 1 0 EMPTY +Pos 1 1 EMPTY +Pos 0 1 EMPTY + +Index 17 XFLIP YFLIP +Pos 1 0 EMPTY +Pos 1 1 EMPTY +Pos 0 1 EMPTY +Pos -1 1 EMPTY +Pos -1 0 EMPTY + +Index 17 ROTATE XFLIP YFLIP +Pos 0 -1 EMPTY +Pos -1 -1 EMPTY +Pos -1 0 EMPTY +Pos -1 1 EMPTY +Pos 0 1 EMPTY + +Index 18 +Pos 1 -1 FULL +Pos -1 1 FULL +Pos 1 0 EMPTY +Pos 1 1 EMPTY +Pos 0 1 EMPTY +Pos 0 -1 EMPTY +Pos -1 -1 EMPTY +Pos -1 0 EMPTY + +Index 18 ROTATE +Pos -1 -1 FULL +Pos 1 1 FULL +Pos 0 -1 EMPTY +Pos 1 -1 EMPTY +Pos 1 0 EMPTY +Pos -1 0 EMPTY +Pos -1 1 EMPTY +Pos 0 1 EMPTY + +Index 19 +Pos -1 1 FULL +Pos -1 -1 EMPTY +Pos 0 -1 EMPTY +Pos 1 -1 EMPTY +Pos 1 0 EMPTY +Pos 1 1 EMPTY +Pos 0 1 EMPTY +Pos -1 0 EMPTY + +Index 19 ROTATE +Pos -1 -1 FULL +Pos 0 -1 EMPTY +Pos 1 -1 EMPTY +Pos 1 0 EMPTY +Pos 1 1 EMPTY +Pos 0 1 EMPTY +Pos -1 1 EMPTY +Pos -1 0 EMPTY + +Index 19 XFLIP YFLIP +Pos 1 -1 FULL +Pos -1 -1 EMPTY +Pos 0 -1 EMPTY +Pos 1 0 EMPTY +Pos 1 1 EMPTY +Pos 0 1 EMPTY +Pos -1 1 EMPTY +Pos -1 0 EMPTY + +Index 19 ROTATE XFLIP YFLIP +Pos 1 1 FULL +Pos -1 -1 EMPTY +Pos 0 -1 EMPTY +Pos 1 -1 EMPTY +Pos 1 0 EMPTY +Pos 0 1 EMPTY +Pos -1 1 EMPTY +Pos -1 0 EMPTY + +Index 20 +Pos -1 -1 EMPTY +Pos 0 -1 EMPTY +Pos 1 -1 EMPTY +Pos 1 0 EMPTY +Pos 1 1 EMPTY +Pos 0 1 EMPTY +Pos -1 1 EMPTY +Pos -1 0 EMPTY diff --git a/automapper/ddnet_tiles.rules b/automapper/ddnet_tiles.rules new file mode 100644 index 0000000..ca92507 --- /dev/null +++ b/automapper/ddnet_tiles.rules @@ -0,0 +1,74 @@ +[DDNet] +Index 110 + +Index 94 +Pos 0 -1 EMPTY +Pos -1 0 EMPTY +Pos 0 1 FULL +Pos 1 0 FULL +Pos 1 -1 EMPTY +Pos -1 1 EMPTY +Pos -1 -1 EMPTY + +Index 94 XFLIP +Pos 0 -1 EMPTY +Pos 1 0 EMPTY +Pos 0 1 FULL +Pos -1 0 FULL +Pos -1 -1 EMPTY +Pos 1 1 EMPTY +Pos 1 -1 EMPTY + +Index 94 YFLIP +Pos 0 1 EMPTY +Pos -1 0 EMPTY +Pos 0 -1 FULL +Pos 1 0 FULL +Pos 1 1 EMPTY +Pos -1 -1 EMPTY +Pos -1 1 EMPTY + +Index 94 XFLIP YFLIP +Pos 0 1 EMPTY +Pos 1 0 EMPTY +Pos 0 -1 FULL +Pos -1 0 FULL +Pos -1 1 EMPTY +Pos 1 -1 EMPTY +Pos 1 1 EMPTY + +Index 108 +Pos 0 0 EMPTY +Pos 0 -1 EMPTY +Pos -1 0 EMPTY +Pos 0 1 FULL +Pos 1 0 FULL +Pos 0 1 NOTINDEX -1 +Pos 1 0 NOTINDEX -1 + +Index 108 XFLIP +Pos 0 0 EMPTY +Pos 0 -1 EMPTY +Pos 1 0 EMPTY +Pos 0 1 FULL +Pos -1 0 FULL +Pos 0 1 NOTINDEX -1 +Pos -1 0 NOTINDEX -1 + +Index 108 YFLIP +Pos 0 0 EMPTY +Pos 0 1 EMPTY +Pos -1 0 EMPTY +Pos 0 -1 FULL +Pos 1 0 FULL +Pos 0 -1 NOTINDEX -1 +Pos 1 0 NOTINDEX -1 + +Index 108 XFLIP YFLIP +Pos 0 0 EMPTY +Pos 0 1 EMPTY +Pos 1 0 EMPTY +Pos 0 -1 FULL +Pos -1 0 FULL +Pos 0 -1 NOTINDEX -1 +Pos -1 0 NOTINDEX -1 diff --git a/automapper/ddnet_walls.rules b/automapper/ddnet_walls.rules new file mode 100644 index 0000000..7355aa1 --- /dev/null +++ b/automapper/ddnet_walls.rules @@ -0,0 +1,424 @@ +[Basic Walls] +Index 16 + +#1W2W3W4W +Index 17 +Pos 0 -1 EMPTY +Pos 0 1 EMPTY +Pos -1 0 EMPTY +Pos 1 0 EMPTY + +#1W2W3S4W +Index 18 +Pos 0 -1 EMPTY +Pos -1 0 EMPTY +Pos 0 1 FULL +Pos 1 0 EMPTY + +#1W2W3S4W +Index 18 YFLIP +Pos 0 -1 FULL +Pos -1 0 EMPTY +Pos 0 1 EMPTY +Pos 1 0 EMPTY + +#1W2S3S4W +Index 19 +Pos 0 -1 EMPTY +Pos -1 0 EMPTY +Pos 0 1 FULL +Pos 1 0 FULL +Pos 1 1 FULL + +#1W2S3S4W +Index 19 YFLIP +Pos 0 -1 FULL +Pos -1 0 EMPTY +Pos 0 1 EMPTY +Pos 1 0 FULL +Pos 1 -1 FULL + +#1W2S3S4W +Index 19 XFLIP +Pos 0 -1 EMPTY +Pos 0 1 FULL +Pos -1 0 FULL +Pos 1 0 EMPTY +Pos -1 1 FULL + +#1W2S3S4W +Index 19 XFLIP YFLIP +Pos -1 -1 FULL +Pos 0 -1 FULL +Pos -1 0 FULL +Pos 1 0 EMPTY +Pos 0 1 EMPTY + +#1W2S3W4S +Index 20 +Pos -1 0 FULL +Pos 1 0 FULL +Pos 0 -1 EMPTY +Pos 0 1 EMPTY + +#1W2S3S4S +Index 21 +Pos -1 1 FULL +Pos 0 1 FULL +Pos 1 1 FULL +Pos 1 0 FULL +Pos -1 0 FULL +Pos 0 -1 EMPTY + +#1W2S3S4S +Index 21 YFLIP +Pos -1 -1 FULL +Pos 1 -1 FULL +Pos 0 -1 FULL +Pos 1 0 FULL +Pos -1 0 FULL +Pos 0 1 EMPTY + +#1D2D3D4D +Index 32 +Pos -1 -1 EMPTY +Pos 0 -1 FULL +Pos 1 -1 EMPTY +Pos -1 0 FULL +Pos 1 0 FULL +Pos -1 1 EMPTY +Pos 0 1 FULL +Pos 1 1 EMPTY + +#1D2S3D4D +Index 33 +Pos -1 -1 EMPTY +Pos 0 -1 FULL +Pos 1 -1 EMPTY +Pos -1 0 FULL +Pos 1 0 FULL +Pos -1 1 EMPTY +Pos 0 1 FULL +Pos 1 1 FULL + +#1D2S3D4D +Index 33 XFLIP +Pos -1 -1 EMPTY +Pos 0 -1 FULL +Pos 1 -1 EMPTY +Pos -1 0 FULL +Pos 1 0 FULL +Pos -1 1 FULL +Pos 0 1 FULL +Pos 1 1 EMPTY + +#1D2S3D4D +Index 33 YFLIP +Pos -1 -1 EMPTY +Pos 0 -1 FULL +Pos 1 -1 FULL +Pos -1 0 FULL +Pos 1 0 FULL +Pos -1 1 EMPTY +Pos 0 1 FULL +Pos 1 1 EMPTY + +#1D2S3D4D +Index 33 XFLIP YFLIP +Pos -1 -1 FULL +Pos 0 -1 FULL +Pos 1 -1 EMPTY +Pos -1 0 FULL +Pos 1 0 FULL +Pos -1 1 EMPTY +Pos 0 1 FULL +Pos 1 1 EMPTY + +#1D2S3S4D +Index 34 +Pos -1 -1 EMPTY +Pos 0 -1 FULL +Pos 1 -1 EMPTY +Pos -1 0 FULL +Pos 1 0 FULL +Pos -1 1 FULL +Pos 0 1 FULL +Pos 1 1 FULL + +#1D2S3S4D +Index 34 YFLIP +Pos -1 -1 FULL +Pos 0 -1 FULL +Pos 1 -1 FULL +Pos -1 0 FULL +Pos 1 0 FULL +Pos -1 1 EMPTY +Pos 0 1 FULL +Pos 1 1 EMPTY + +#1S2S3S4D +Index 35 +Pos -1 -1 EMPTY +Pos 0 -1 FULL +Pos 1 -1 FULL +Pos -1 0 FULL +Pos 1 0 FULL +Pos -1 1 FULL +Pos 0 1 FULL +Pos 1 1 FULL + +#1S2S3S4D +Index 35 XFLIP +Pos -1 -1 FULL +Pos 0 -1 FULL +Pos 1 -1 EMPTY +Pos -1 0 FULL +Pos 1 0 FULL +Pos -1 1 FULL +Pos 0 1 FULL +Pos 1 1 FULL + +#1S2S3S4D +Index 35 YFLIP +Pos -1 -1 FULL +Pos 0 -1 FULL +Pos 1 -1 FULL +Pos -1 0 FULL +Pos 1 0 FULL +Pos -1 1 EMPTY +Pos 0 1 FULL +Pos 1 1 FULL + +#1S2S3S4D +Index 35 XFLIP YFLIP +Pos -1 -1 FULL +Pos 0 -1 FULL +Pos 1 -1 FULL +Pos -1 0 FULL +Pos 1 0 FULL +Pos -1 1 FULL +Pos 0 1 FULL +Pos 1 1 EMPTY + +#1S2D3S4D +Index 36 +Pos -1 -1 EMPTY +Pos 0 -1 FULL +Pos 1 -1 FULL +Pos -1 0 FULL +Pos 1 0 FULL +Pos -1 1 FULL +Pos 0 1 FULL +Pos 1 1 EMPTY + +#1S2D3S4D +Index 36 XFLIP +Pos -1 -1 FULL +Pos 0 -1 FULL +Pos 1 -1 EMPTY +Pos -1 0 FULL +Pos 1 0 FULL +Pos -1 1 EMPTY +Pos 0 1 FULL +Pos 1 1 FULL + +#1S2S3D4D +Index 37 +Pos -1 -1 EMPTY +Pos 0 -1 FULL +Pos 1 -1 FULL +Pos -1 0 FULL +Pos 1 0 FULL +Pos -1 1 EMPTY +Pos 0 1 FULL +Pos 1 1 FULL + +#1S2S3D4D +Index 37 XFLIP +Pos -1 -1 FULL +Pos 0 -1 FULL +Pos 1 -1 EMPTY +Pos -1 0 FULL +Pos 1 0 FULL +Pos -1 1 FULL +Pos 0 1 FULL +Pos 1 1 EMPTY + +#1W2D3S4W +Index 48 +Pos 0 -1 EMPTY +Pos -1 0 EMPTY +Pos 0 1 FULL +Pos 1 1 EMPTY +Pos 1 0 FULL + +#1W2D3S4W +Index 48 XFLIP +Pos 0 -1 EMPTY +Pos 1 0 EMPTY +Pos -1 1 EMPTY +Pos 0 1 FULL +Pos -1 0 FULL + +#1W2D3S4W +Index 48 YFLIP +Pos -1 0 EMPTY +Pos 0 1 EMPTY +Pos 1 -1 EMPTY +Pos 0 -1 FULL +Pos 1 0 FULL + +#1W2D3S4W +Index 48 XFLIP YFLIP +Pos 1 0 EMPTY +Pos 0 1 EMPTY +Pos -1 -1 EMPTY +Pos 0 -1 FULL +Pos -1 0 FULL + +#1W2D3D4S +Index 49 +Pos -1 1 EMPTY +Pos 0 1 FULL +Pos 1 1 EMPTY +Pos 1 0 FULL +Pos -1 0 FULL +Pos 0 -1 EMPTY + +#1W2D3D4S +Index 49 YFLIP +Pos -1 -1 EMPTY +Pos 1 -1 EMPTY +Pos 0 -1 FULL +Pos 1 0 FULL +Pos -1 0 FULL +Pos 0 1 EMPTY + +#1W2S3D4S +Index 50 +Pos -1 1 EMPTY +Pos 0 1 FULL +Pos 1 1 FULL +Pos 1 0 FULL +Pos -1 0 FULL +Pos 0 -1 EMPTY + +#1W2S3D4S +Index 50 XFLIP +Pos -1 1 FULL +Pos 0 1 FULL +Pos 1 1 EMPTY +Pos 1 0 FULL +Pos -1 0 FULL +Pos 0 -1 EMPTY + +#1W2S3D4S +Index 50 YFLIP +Pos -1 -1 EMPTY +Pos 1 -1 FULL +Pos 0 -1 FULL +Pos 1 0 FULL +Pos -1 0 FULL +Pos 0 1 EMPTY + +#1W2S3D4S +Index 50 XFLIP YFLIP +Pos -1 -1 FULL +Pos 1 -1 EMPTY +Pos 0 -1 FULL +Pos 1 0 FULL +Pos -1 0 FULL +Pos 0 1 EMPTY + +#1S2W3S4W +Index 51 +Pos -1 0 EMPTY +Pos 1 0 EMPTY +Pos 0 -1 FULL +Pos 0 1 FULL + +#1W2S3W4W +Index 52 +Pos 0 -1 EMPTY +Pos -1 0 EMPTY +Pos 1 0 FULL +Pos 0 1 EMPTY + +#1W2S3W4W +Index 52 XFLIP +Pos 0 -1 EMPTY +Pos -1 0 FULL +Pos 1 0 EMPTY +Pos 0 1 EMPTY + +#1S2S3S4W +Index 53 +Pos 0 -1 FULL +Pos -1 0 EMPTY +Pos 1 0 FULL +Pos 0 1 FULL +Pos 1 -1 FULL +Pos 1 1 FULL + +#1S2S3S4W +Index 53 XFLIP +Pos 0 -1 FULL +Pos -1 -1 FULL +Pos -1 0 FULL +Pos -1 1 FULL +Pos 1 0 EMPTY +Pos 0 1 FULL + +#1D2D3S4W +Index 64 +Pos 0 -1 FULL +Pos -1 0 EMPTY +Pos 1 0 FULL +Pos 0 1 FULL +Pos 1 -1 EMPTY +Pos 1 1 EMPTY + +#1D2D3S4W +Index 64 XFLIP +Pos 0 -1 FULL +Pos -1 -1 EMPTY +Pos -1 0 FULL +Pos -1 1 EMPTY +Pos 1 0 EMPTY +Pos 0 1 FULL + +#1S2W3D4S +Index 65 +Pos 0 -1 FULL +Pos -1 -1 FULL +Pos -1 0 FULL +Pos -1 1 EMPTY +Pos 1 0 EMPTY +Pos 0 1 FULL + +#1S2W3D4S +Index 65 XFLIP +Pos 0 -1 FULL +Pos -1 0 EMPTY +Pos 1 0 FULL +Pos 0 1 FULL +Pos 1 -1 FULL +Pos 1 1 EMPTY + +#1S2W3D4S +Index 65 YFLIP +Pos 0 -1 FULL +Pos -1 -1 EMPTY +Pos -1 0 FULL +Pos -1 1 FULL +Pos 1 0 EMPTY +Pos 0 1 FULL + +#1S2W3D4S +Index 65 XFLIP YFLIP +Pos 0 -1 FULL +Pos -1 0 EMPTY +Pos 1 0 FULL +Pos 0 1 FULL +Pos 1 -1 EMPTY +Pos 1 1 FULL diff --git a/src/bin/automap_test.rs b/src/bin/automap_test.rs new file mode 100644 index 0000000..2082381 --- /dev/null +++ b/src/bin/automap_test.rs @@ -0,0 +1,15 @@ +use std::path::PathBuf; + +use gores_mapgen_rust::config::GenerationConfig; +use gores_mapgen_rust::generator::Generator; +use gores_mapgen_rust::random::Seed; + +fn main() { + let map = + Generator::generate_map(30_000, &Seed::from_u64(42), &GenerationConfig::default()).unwrap(); + + map.export(&PathBuf::from( + // "/home/tobi/.local/share/ddnet/maps/automap_out.map", + "./automap_out.map", + )); +} diff --git a/src/map.rs b/src/map.rs index 069b7b2..442e1b4 100644 --- a/src/map.rs +++ b/src/map.rs @@ -1,8 +1,11 @@ use crate::{position::Position, walker::CuteWalker}; use ndarray::{s, Array2}; use rand_distr::num_traits::ToPrimitive; -use std::path::PathBuf; -use twmap::{GameLayer, GameTile, TileFlags, TilemapLayer, TwMap}; +use std::{borrow::BorrowMut, fs, path::PathBuf}; +use twmap::{ + automapper::Automapper, GameLayer, GameTile, Layer, Tile, TileFlags, TilemapLayer, TilesLayer, + TwMap, +}; const CHUNK_SIZE: usize = 5; @@ -30,6 +33,14 @@ impl BlockType { BlockType::Finish => 34, } } + + /// if block type should be included in tw hookable layer + fn in_tw_hookable_layer(&self) -> bool { + match self { + BlockType::Hookable | BlockType::Platform => true, + _ => false, + } + } } pub enum KernelType { @@ -190,9 +201,43 @@ impl Map { } pub fn export(&self, path: &PathBuf) { - let mut map = TwMap::parse_file("test.map").expect("parsing failed"); + let mut map = TwMap::parse_file("automap_test.map").expect("parsing failed"); map.load().expect("loading failed"); + // get Tiles group + let tile_group = map.groups.get_mut(2).unwrap(); + assert_eq!(tile_group.name, "Tiles"); + + // get Hookable and Freeze layer in Tiles group + if let Some(Layer::Tiles(layer)) = tile_group.layers.get_mut(1) { + assert_eq!(layer.name, "Hookable"); + + let image_name = map.images[layer.image.unwrap() as usize].name(); + let config_index = layer.automapper_config.config.unwrap(); + + let tiles = layer.tiles_mut().unwrap_mut(); + *tiles = Array2::::default((self.width, self.height)); + + for ((x, y), value) in self.grid.indexed_iter() { + if value.in_tw_hookable_layer() { + tiles[[y, x]] = Tile::new(1, TileFlags::empty()) + } + } + + let file = fs::read_to_string("automapper/ddnet_walls.rules") + .expect("failed to read .rules file"); + let automapper = Automapper::parse(image_name.to_string(), &file) + .expect("failed to parse .rules file"); + let config = automapper + .configs + .get(config_index as usize) + .expect("failed to fetch config"); + + config.run(1337, tiles); + } else { + panic!("coulnt get Hookable layer at index 0"); + }; + // get game layer let game_layer = map .find_physics_layer_mut::() From 2da8b89d41e6402f1cbf2889b74883e5c13785b0 Mon Sep 17 00:00:00 2001 From: tobi Date: Thu, 25 Apr 2024 22:54:18 +0200 Subject: [PATCH 2/3] Restructure tw export code --- src/lib.rs | 1 + src/map.rs | 64 +++-------------------------------------- src/twmap_export.rs | 69 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+), 60 deletions(-) create mode 100644 src/twmap_export.rs diff --git a/src/lib.rs b/src/lib.rs index 6872a26..dea2715 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -7,4 +7,5 @@ pub mod kernel; pub mod map; pub mod position; pub mod random; +pub mod twmap_export; pub mod walker; diff --git a/src/map.rs b/src/map.rs index 442e1b4..fe3a8c0 100644 --- a/src/map.rs +++ b/src/map.rs @@ -1,4 +1,4 @@ -use crate::{position::Position, walker::CuteWalker}; +use crate::{position::Position, twmap_export::TwExport, walker::CuteWalker}; use ndarray::{s, Array2}; use rand_distr::num_traits::ToPrimitive; use std::{borrow::BorrowMut, fs, path::PathBuf}; @@ -22,7 +22,7 @@ pub enum BlockType { impl BlockType { /// maps BlockType to tw game layer id for map export - fn to_tw_game_id(&self) -> u8 { + pub fn to_tw_game_id(&self) -> u8 { match self { BlockType::Empty => 0, BlockType::Hookable => 1, @@ -35,7 +35,7 @@ impl BlockType { } /// if block type should be included in tw hookable layer - fn in_tw_hookable_layer(&self) -> bool { + pub fn in_tw_hookable_layer(&self) -> bool { match self { BlockType::Hookable | BlockType::Platform => true, _ => false, @@ -201,63 +201,7 @@ impl Map { } pub fn export(&self, path: &PathBuf) { - let mut map = TwMap::parse_file("automap_test.map").expect("parsing failed"); - map.load().expect("loading failed"); - - // get Tiles group - let tile_group = map.groups.get_mut(2).unwrap(); - assert_eq!(tile_group.name, "Tiles"); - - // get Hookable and Freeze layer in Tiles group - if let Some(Layer::Tiles(layer)) = tile_group.layers.get_mut(1) { - assert_eq!(layer.name, "Hookable"); - - let image_name = map.images[layer.image.unwrap() as usize].name(); - let config_index = layer.automapper_config.config.unwrap(); - - let tiles = layer.tiles_mut().unwrap_mut(); - *tiles = Array2::::default((self.width, self.height)); - - for ((x, y), value) in self.grid.indexed_iter() { - if value.in_tw_hookable_layer() { - tiles[[y, x]] = Tile::new(1, TileFlags::empty()) - } - } - - let file = fs::read_to_string("automapper/ddnet_walls.rules") - .expect("failed to read .rules file"); - let automapper = Automapper::parse(image_name.to_string(), &file) - .expect("failed to parse .rules file"); - let config = automapper - .configs - .get(config_index as usize) - .expect("failed to fetch config"); - - config.run(1337, tiles); - } else { - panic!("coulnt get Hookable layer at index 0"); - }; - - // get game layer - let game_layer = map - .find_physics_layer_mut::() - .unwrap() - .tiles_mut() - .unwrap_mut(); - - *game_layer = Array2::::from_elem( - (self.width, self.height), - GameTile::new(0, TileFlags::empty()), - ); - - // modify game layer - for ((x, y), value) in self.grid.indexed_iter() { - game_layer[[y, x]] = GameTile::new(value.to_tw_game_id(), TileFlags::empty()) - } - - // save map - println!("exporting map to {:?}", &path); - map.save_file(path).expect("saving failed"); + TwExport::export(&self, &path) } pub fn pos_in_bounds(&self, pos: &Position) -> bool { diff --git a/src/twmap_export.rs b/src/twmap_export.rs new file mode 100644 index 0000000..090d50b --- /dev/null +++ b/src/twmap_export.rs @@ -0,0 +1,69 @@ +use crate::map::Map; +use ndarray::Array2; +use std::{fs, path::PathBuf}; +use twmap::{ + automapper::Automapper, GameLayer, GameTile, Layer, Tile, TileFlags, TilemapLayer, TwMap, +}; + +pub struct TwExport; + +impl TwExport { + pub fn export(map: &Map, path: &PathBuf) { + let mut tw_map = TwMap::parse_file("automap_test.map").expect("parsing failed"); + tw_map.load().expect("loading failed"); + + // get Tiles group + let tile_group = tw_map.groups.get_mut(2).unwrap(); + assert_eq!(tile_group.name, "Tiles"); + + // get Hookable and Freeze layer in Tiles group + if let Some(Layer::Tiles(layer)) = tile_group.layers.get_mut(1) { + assert_eq!(layer.name, "Hookable"); + + let image_name = tw_map.images[layer.image.unwrap() as usize].name(); + let config_index = layer.automapper_config.config.unwrap(); + + let tiles = layer.tiles_mut().unwrap_mut(); + *tiles = Array2::::default((map.width, map.height)); + + for ((x, y), value) in map.grid.indexed_iter() { + if value.in_tw_hookable_layer() { + tiles[[y, x]] = Tile::new(1, TileFlags::empty()) + } + } + + let file = fs::read_to_string("automapper/ddnet_walls.rules") + .expect("failed to read .rules file"); + let automapper = Automapper::parse(image_name.to_string(), &file) + .expect("failed to parse .rules file"); + let config = automapper + .configs + .get(config_index as usize) + .expect("failed to fetch config"); + + config.run(1337, tiles); + } else { + panic!("coulnt get Hookable layer at index 0"); + }; + + // get game layer + let game_layer = tw_map + .find_physics_layer_mut::() + .unwrap() + .tiles_mut() + .unwrap_mut(); + + *game_layer = Array2::::from_elem( + (map.width, map.height), + GameTile::new(0, TileFlags::empty()), + ); + + // modify game layer + for ((x, y), value) in map.grid.indexed_iter() { + game_layer[[y, x]] = GameTile::new(value.to_tw_game_id(), TileFlags::empty()) + } + + // save map + println!("exporting map to {:?}", &path); + } +} From 70f3f1de8906ef314de097113cca552d4b434a88 Mon Sep 17 00:00:00 2001 From: tobi Date: Fri, 26 Apr 2024 00:04:41 +0200 Subject: [PATCH 3/3] Update automapping --- automap_out.map | Bin 0 -> 27470 bytes src/bin/automap_test.rs | 4 +-- src/config.rs | 6 ++-- src/map.rs | 9 ++--- src/twmap_export.rs | 78 ++++++++++++++++++++++++++++------------ 5 files changed, 62 insertions(+), 35 deletions(-) create mode 100644 automap_out.map diff --git a/automap_out.map b/autom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Sm)Dz8hr-L<7*OM4xK^h02G=25oGK^$W2X9gWFe9Dw@#P> zrAaYBc5qvxTW!wl;peJ{2~laMQjfnP%Ikzk1}vX2_KKVymx=3DEqV?vB<5zk6@~t> zT-96LKm6JxOcN4z)!q*c?LjAMT`tx_$5y`A38n8y?I}g+je53h*>mMoZQf95DfPy^ z@za)M>CtQZaDMH7TSmebLfsBm5vj~B6_0@&;g|5sXSgf5sV16u>c~$oE ks`SU&@ycuzn-MD^R^UBh9J64CCE^Ciw|dEMwkjb0522iCkN^Mx literal 0 HcmV?d00001 diff --git a/src/bin/automap_test.rs b/src/bin/automap_test.rs index 2082381..1f9567a 100644 --- a/src/bin/automap_test.rs +++ b/src/bin/automap_test.rs @@ -9,7 +9,7 @@ fn main() { Generator::generate_map(30_000, &Seed::from_u64(42), &GenerationConfig::default()).unwrap(); map.export(&PathBuf::from( - // "/home/tobi/.local/share/ddnet/maps/automap_out.map", - "./automap_out.map", + "/home/tobi/.local/share/ddnet/maps/automap_out.map", + // "./automap_out.map", )); } diff --git a/src/config.rs b/src/config.rs index 2542d08..5a9435b 100644 --- a/src/config.rs +++ b/src/config.rs @@ -8,7 +8,7 @@ use std::io::Write; #[derive(RustEmbed)] #[folder = "configs/"] -pub struct Configs; +pub struct GenerationConfigStorage; #[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] #[serde(default)] @@ -77,8 +77,8 @@ impl GenerationConfig { pub fn get_configs() -> HashMap { let mut configs = HashMap::new(); - for file_name in Configs::iter() { - let file = Configs::get(&file_name).unwrap(); + for file_name in GenerationConfigStorage::iter() { + let file = GenerationConfigStorage::get(&file_name).unwrap(); let data = std::str::from_utf8(&file.data).unwrap(); let config: GenerationConfig = serde_json::from_str(&data).unwrap(); configs.insert(config.name.clone(), config); diff --git a/src/map.rs b/src/map.rs index fe3a8c0..ff852fd 100644 --- a/src/map.rs +++ b/src/map.rs @@ -1,11 +1,7 @@ use crate::{position::Position, twmap_export::TwExport, walker::CuteWalker}; use ndarray::{s, Array2}; use rand_distr::num_traits::ToPrimitive; -use std::{borrow::BorrowMut, fs, path::PathBuf}; -use twmap::{ - automapper::Automapper, GameLayer, GameTile, Layer, Tile, TileFlags, TilemapLayer, TilesLayer, - TwMap, -}; +use std::path::PathBuf; const CHUNK_SIZE: usize = 5; @@ -34,8 +30,7 @@ impl BlockType { } } - /// if block type should be included in tw hookable layer - pub fn in_tw_hookable_layer(&self) -> bool { + pub fn is_hookable(&self) -> bool { match self { BlockType::Hookable | BlockType::Platform => true, _ => false, diff --git a/src/twmap_export.rs b/src/twmap_export.rs index 090d50b..a729a64 100644 --- a/src/twmap_export.rs +++ b/src/twmap_export.rs @@ -1,50 +1,81 @@ -use crate::map::Map; +use crate::map::{BlockType, Map}; use ndarray::Array2; -use std::{fs, path::PathBuf}; +use rust_embed::RustEmbed; +use std::path::PathBuf; use twmap::{ - automapper::Automapper, GameLayer, GameTile, Layer, Tile, TileFlags, TilemapLayer, TwMap, + automapper::{self, Automapper}, + GameLayer, GameTile, Layer, Tile, TileFlags, TilemapLayer, TilesLayer, TwMap, }; +#[derive(RustEmbed)] +#[folder = "automapper/"] +pub struct AutoMapperConfigs; + +impl AutoMapperConfigs { + pub fn get_config(name: String) -> Automapper { + let file = AutoMapperConfigs::get(&(name.clone() + ".rules")) + .expect("automapper rule config not found"); + let data = std::str::from_utf8(&file.data).unwrap(); + + Automapper::parse(name, &data).expect("failed to parse .rules file") + } +} + pub struct TwExport; impl TwExport { - pub fn export(map: &Map, path: &PathBuf) { - let mut tw_map = TwMap::parse_file("automap_test.map").expect("parsing failed"); - tw_map.load().expect("loading failed"); + pub fn get_automapper_config(rule_name: String, layer: &TilesLayer) -> automapper::Config { + let config_index = layer.automapper_config.config.unwrap(); + let automapper = AutoMapperConfigs::get_config(rule_name); + let automapper_config = automapper + .configs + .get(config_index as usize) + .expect("coulnt fetch automapper config via index"); - // get Tiles group + automapper_config.clone() + } + + pub fn process_layer( + tw_map: &mut TwMap, + map: &Map, + layer_index: &usize, + layer_name: &str, + block_type_in_layer: F, + ) where + F: Fn(&BlockType) -> bool, + { let tile_group = tw_map.groups.get_mut(2).unwrap(); assert_eq!(tile_group.name, "Tiles"); - // get Hookable and Freeze layer in Tiles group - if let Some(Layer::Tiles(layer)) = tile_group.layers.get_mut(1) { - assert_eq!(layer.name, "Hookable"); + if let Some(Layer::Tiles(layer)) = tile_group.layers.get_mut(*layer_index) { + assert_eq!(layer.name, layer_name); let image_name = tw_map.images[layer.image.unwrap() as usize].name(); - let config_index = layer.automapper_config.config.unwrap(); + let automapper_config = TwExport::get_automapper_config(image_name.clone(), &layer); let tiles = layer.tiles_mut().unwrap_mut(); *tiles = Array2::::default((map.width, map.height)); for ((x, y), value) in map.grid.indexed_iter() { - if value.in_tw_hookable_layer() { + if block_type_in_layer(&value) { tiles[[y, x]] = Tile::new(1, TileFlags::empty()) } } - let file = fs::read_to_string("automapper/ddnet_walls.rules") - .expect("failed to read .rules file"); - let automapper = Automapper::parse(image_name.to_string(), &file) - .expect("failed to parse .rules file"); - let config = automapper - .configs - .get(config_index as usize) - .expect("failed to fetch config"); - - config.run(1337, tiles); + automapper_config.run(3777777777, tiles) // thanks Tater for the epic **random** seed } else { - panic!("coulnt get Hookable layer at index 0"); + panic!("coulnt get layer at index"); }; + } + + pub fn export(map: &Map, path: &PathBuf) { + let mut tw_map = TwMap::parse_file("automap_test.map").expect("parsing failed"); + tw_map.load().expect("loading failed"); + + TwExport::process_layer(&mut tw_map, &map, &0, "Freeze", |t| { + (*t == BlockType::Freeze) || BlockType::is_hookable(&t) + }); + TwExport::process_layer(&mut tw_map, &map, &1, "Hookable", BlockType::is_hookable); // get game layer let game_layer = tw_map @@ -65,5 +96,6 @@ impl TwExport { // save map println!("exporting map to {:?}", &path); + tw_map.save_file(&path).expect("failed to write map file"); } }