feat: divided wildcard into 'known' and 'true'

This commit is contained in:
Sara Gerretsen 2026-03-31 16:28:35 +02:00
parent a3b9965766
commit 5f6f967aab
2 changed files with 87 additions and 36 deletions

View file

@ -41,7 +41,7 @@ bool Sentence::check_match_at(Vector2i at, Ref<Sentence> pattern) {
for (Vector2i itr{ 0, 0 }; itr.y < pattern_size.y; ++itr.y) {
for (; itr.x < pattern_size.x; ++itr.x) {
Symbol a{ get_at(at + itr) }, b{ pattern->get_at(itr) };
if (a != b && (b != U'*' || a == U'u')) {
if (a != b && b != '*' && (b != U'#' || a == U'u')) {
return false; // difference found
}
}
@ -54,7 +54,7 @@ void Sentence::write_subsentence(Vector2i at, Ref<Sentence> sentence) {
for (Vector2i pos{ 0, 0 }; pos.y < sentence->get_size().y; ++pos.y) {
for (; pos.x < sentence->get_size().x; ++pos.x) {
Symbol write{ sentence->get_at(pos) };
if (write != U'*') { // wildcards don't write
if (write != U'*' && write != U'#') { // wildcards don't write
set_at(at + pos, write);
}
}

View file

@ -1,6 +1,19 @@
[gd_scene format=3 uid="uid://cak2tf2adjv8j"]
[ext_resource type="PackedScene" uid="uid://bn7d8n5mbabu3" path="res://objects/tiles/path.tscn" id="1_wail4"]
[ext_resource type="PackedScene" uid="uid://cts1ix6iw1jpc" path="res://objects/tiles/start.tscn" id="2_srduu"]
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_wail4"]
sky_horizon_color = Color(0.66224277, 0.6717428, 0.6867428, 1)
ground_horizon_color = Color(0.66224277, 0.6717428, 0.6867428, 1)
[sub_resource type="Sky" id="Sky_srduu"]
sky_material = SubResource("ProceduralSkyMaterial_wail4")
[sub_resource type="Environment" id="Environment_s5a2w"]
background_mode = 2
sky = SubResource("Sky_srduu")
glow_enabled = true
[sub_resource type="Sentence" id="Sentence_bb2w7"]
size = Vector2i(20, 20)
@ -29,33 +42,17 @@ uuuuuuuuuuuuuuuuuuuu"
size = Vector2i(5, 3)
symbols_string = "uuuuu
uuuuu
*pxp*"
#pxp#"
[sub_resource type="Sentence" id="Sentence_yc5ro"]
size = Vector2i(5, 3)
symbols_string = "uuuuu
upxpu
*pup*"
[sub_resource type="Sentence" id="Sentence_wyxho"]
size = Vector2i(5, 5)
symbols_string = "uuuuu
uuuuu
*p*p*
uuuuu
uuuuu"
[sub_resource type="Sentence" id="Sentence_q0ye3"]
size = Vector2i(5, 5)
symbols_string = "uuuuu
upxpu
*pup*
upxpu
uuuuu"
#pup#"
[sub_resource type="Sentence" id="Sentence_7f72c"]
size = Vector2i(5, 3)
symbols_string = "*p*p*
symbols_string = "#p#p#
uuuuu
uuuuu"
@ -65,55 +62,109 @@ symbols_string = "*pup*
upxpu
uuuuu"
[sub_resource type="Sentence" id="Sentence_wyxho"]
size = Vector2i(5, 5)
symbols_string = "uuuuu
uuuuu
#p#p#
uuuuu
uuuuu"
[sub_resource type="Sentence" id="Sentence_q0ye3"]
size = Vector2i(5, 5)
symbols_string = "uuuuu
upxpu
#pup#
upxpu
uuuuu"
[sub_resource type="Sentence" id="Sentence_w0mg0"]
size = Vector2i(4, 5)
symbols_string = "uuuu
##u*
u##*
##u*
uuuu"
[sub_resource type="Sentence" id="Sentence_06kf8"]
size = Vector2i(4, 5)
symbols_string = "uuuu
##pp
uuu#
##pp
uuuu"
[sub_resource type="Sentence" id="Sentence_wail4"]
size = Vector2i(5, 3)
symbols_string = "uuuuu
up*pu
**u**"
up#pu
*#u#*"
[sub_resource type="Sentence" id="Sentence_srduu"]
size = Vector2i(5, 3)
symbols_string = "upxpu
upupu
**u**"
##u##"
[sub_resource type="Sentence" id="Sentence_c7dwr"]
size = Vector2i(5, 5)
symbols_string = "uuuuu
uuuuu
uuuuu
uuuuu
uuuuu"
[node name="Dungeon" type="Node3D" unique_id=719313039]
[node name="WorldEnvironment" type="WorldEnvironment" parent="." unique_id=860593247]
environment = SubResource("Environment_s5a2w")
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="." unique_id=117999696]
transform = Transform3D(-0.8660254, -0.43301278, 0.25, 0, 0.49999997, 0.86602545, -0.50000006, 0.75, -0.43301266, 0, 0, 0)
shadow_enabled = true
[node name="Generator" type="Generator" parent="." unique_id=1532743122]
state = SubResource("Sentence_bb2w7")
tiles_dict = {
"p": ExtResource("1_wail4"),
"s": ExtResource("2_srduu"),
"x": ExtResource("1_wail4")
}
[node name="RepeatRuleUntilFailure" type="RepeatRuleUntilFailure" parent="Generator" unique_id=407316032]
[node name="CompositeRule" type="CompositeRule" parent="Generator/RepeatRuleUntilFailure" unique_id=117678547]
[node name="InitialLayout" type="CompositeRule" parent="Generator/RepeatRuleUntilFailure" unique_id=117678547]
random_order = true
[node name="ZigUp" type="ReplaceRule" parent="Generator/RepeatRuleUntilFailure/CompositeRule" unique_id=1073931523]
[node name="ZigUp" type="ReplaceRule" parent="Generator/RepeatRuleUntilFailure/InitialLayout" unique_id=1073931523]
pattern = SubResource("Sentence_s5a2w")
results_dict = {
SubResource("Sentence_yc5ro"): 1.0
}
[node name="Split" type="ReplaceRule" parent="Generator/RepeatRuleUntilFailure/CompositeRule" unique_id=222066055]
pattern = SubResource("Sentence_wyxho")
results_dict = {
SubResource("Sentence_q0ye3"): 1.0
}
[node name="ZagDown" type="ReplaceRule" parent="Generator/RepeatRuleUntilFailure/CompositeRule" unique_id=1665850421]
[node name="ZagDown" type="ReplaceRule" parent="Generator/RepeatRuleUntilFailure/InitialLayout" unique_id=1665850421]
pattern = SubResource("Sentence_7f72c")
results_dict = {
SubResource("Sentence_pbld3"): 1.0
}
[node name="ExtendLoop" type="ReplaceRule" parent="Generator/RepeatRuleUntilFailure/CompositeRule" unique_id=1207681043]
[node name="Split" type="ReplaceRule" parent="Generator/RepeatRuleUntilFailure/InitialLayout" unique_id=222066055]
pattern = SubResource("Sentence_wyxho")
results_dict = {
SubResource("Sentence_q0ye3"): 1.0
}
[node name="StretchLoop" type="ReplaceRule" parent="Generator/RepeatRuleUntilFailure/InitialLayout" unique_id=995556959]
pattern = SubResource("Sentence_w0mg0")
results_dict = {
SubResource("Sentence_06kf8"): 1.0
}
[node name="ExtendLoop" type="ReplaceRule" parent="Generator/RepeatRuleUntilFailure/InitialLayout" unique_id=1207681043]
pattern = SubResource("Sentence_wail4")
results_dict = {
SubResource("Sentence_srduu"): 1.0
}
[node name="Camera3D" type="Camera3D" parent="Generator" unique_id=1193344185]
transform = Transform3D(-0.8008847, 0.5054234, -0.32113996, 0, 0.5362893, 0.84403425, 0.5988186, 0.67597413, -0.42950585, 0, 10.870714, 0)
[node name="SplitVertical" type="ReplaceRule" parent="Generator/RepeatRuleUntilFailure/InitialLayout" unique_id=1220297709]
pattern = SubResource("Sentence_c7dwr")