chore: adjustments to test rules
This commit is contained in:
parent
fca1b11f1c
commit
5a72b42d81
2 changed files with 29 additions and 20 deletions
|
|
@ -114,7 +114,7 @@ bool CompositeRule::try_apply(Ref<Sentence> sentence) {
|
|||
}
|
||||
|
||||
bool RepeatRuleUntilFailure::try_apply(Ref<Sentence> sentence) {
|
||||
while (!this->rules.get(0)->try_apply(sentence)) {
|
||||
while (this->rules.get(0)->try_apply(sentence)) {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
@ -127,17 +127,16 @@ void ReplaceRule::_bind_methods() {
|
|||
bool ReplaceRule::try_apply(Ref<Sentence> sentence) {
|
||||
ERR_FAIL_COND_V_EDMSG(this->results.size() == 0, false, "ReplaceRule::try_apply failed, no results in list");
|
||||
Vector2i max{ sentence->get_size() - this->pattern->get_size() };
|
||||
bool any_success{ false };
|
||||
for (Vector2i pos{ 0, 0 }; pos.y < max.y; ++pos.y) {
|
||||
for (; pos.x < max.x; ++pos.x) {
|
||||
if (sentence->check_match_at(pos, this->pattern)) {
|
||||
any_success = true;
|
||||
sentence->write_subsentence(pos, this->results[Math::rand() % this->results.size()].first); // TODO pick based on weighed random
|
||||
return true;
|
||||
}
|
||||
}
|
||||
pos.x = 0;
|
||||
}
|
||||
return any_success;
|
||||
return false;
|
||||
}
|
||||
|
||||
void ReplaceRule::set_results_dict(Dictionary dict) {
|
||||
|
|
|
|||
|
|
@ -1,17 +1,27 @@
|
|||
[gd_scene format=3 uid="uid://cak2tf2adjv8j"]
|
||||
|
||||
[sub_resource type="Sentence" id="Sentence_bb2w7"]
|
||||
size = Vector2i(10, 10)
|
||||
symbols_string = "BBBBBBBBBB
|
||||
BuuuuuuuuB
|
||||
BuuuuuuuuB
|
||||
BuuuuuuuuB
|
||||
BuuuuuuuuB
|
||||
BuuuuuuuuB
|
||||
BuuuuuuuuB
|
||||
BuuuuuuuuB
|
||||
BuuuuuuuuB
|
||||
BBBBBBBBBB"
|
||||
size = Vector2i(20, 20)
|
||||
symbols_string = "uuuuuuuuuuuuuuuuuuuu
|
||||
uuuuuuuuuuuuuuuuuuuu
|
||||
uuuuuuuuuuuuuuuuuuuu
|
||||
uuuuuuuuuuuuuuuuuuuu
|
||||
uuuuuuuuuuuuuuuuuuuu
|
||||
uuuuuuuuuuuuuuuuuuuu
|
||||
uuuuuuuuuuuuuuuuuuuu
|
||||
uuuuuuuuuuuuuuuuuuuu
|
||||
uuuuuuuuuuuuuuuuuuuu
|
||||
uuuuuuuuuuuuuuuuuuuu
|
||||
uuuuuuuuuuuuuuuuuuuu
|
||||
uuuuuuuuuuuuuuuuuuuu
|
||||
uuuuuuuuuuuuuuuuuuuu
|
||||
uuuuuuuuuuuuuuuuuuuu
|
||||
uuuuuuuuuuuuuuuuuuuu
|
||||
uuuuuuuuuuuuuuuuuuuu
|
||||
uuuuuuuuuuuuuuuuuuuu
|
||||
uuuuuuuuuuuuuuuuuuuu
|
||||
uuuuuuuuuuuuuuuuuuuu
|
||||
uuuuuuuuuuuuuuuuuuuu"
|
||||
|
||||
[sub_resource type="Sentence" id="Sentence_wail4"]
|
||||
size = Vector2i(3, 1)
|
||||
|
|
@ -25,15 +35,15 @@ symbols_string = "pxp"
|
|||
size = Vector2i(5, 5)
|
||||
symbols_string = "uuuuu
|
||||
uuuuu
|
||||
pxpxp
|
||||
xpxpx
|
||||
uuuuu
|
||||
uuuuu"
|
||||
|
||||
[sub_resource type="Sentence" id="Sentence_yc5ro"]
|
||||
size = Vector2i(5, 5)
|
||||
symbols_string = "uuuuu
|
||||
uppxu
|
||||
pxupp
|
||||
upxpu
|
||||
xpupx
|
||||
uuuuu
|
||||
uuuuu"
|
||||
|
||||
|
|
@ -41,8 +51,8 @@ uuuuu"
|
|||
size = Vector2i(5, 5)
|
||||
symbols_string = "uuuuu
|
||||
uuuuu
|
||||
pxupp
|
||||
uppxu
|
||||
xpupx
|
||||
upxpu
|
||||
uuuuu"
|
||||
|
||||
[node name="Dungeon" type="Node3D" unique_id=719313039]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue