Best way to follow multiple sprites?

146 views
Skip to first unread message

Matt Slaybaugh

unread,
Nov 24, 2013, 8:56:07 AM11/24/13
to puzzle...@googlegroups.com
Imagine a squirrel, who follows acorns when they are in line-of-sight:

[ Squirrel | ... | Acorn ] -> [ > Squirrel | ... |  Acorn ]

This works fine, but what about when there are two or more acorns on the screen, both in line-of-sight at the same time?
The code works, but this error displays:
got caught looping lots in a rule group :O

Do I need to worry about this?
(the situation is not ideal because the player can not always anticipate which way the squirrel will go, but may main concern is the infinite loop)


Alan Hazelden

unread,
Nov 24, 2013, 9:05:16 AM11/24/13
to Matt Slaybaugh, puzzle...@googlegroups.com
This rule should solve that problem:

[ stationary Squirrel | ... | Acorn ] -> [ > Squirrel | ... |  Acorn ]

It's looping because every time you apply the rule to one acorn, the rule can still apply to the other too. If it has to find a non-moving squirrel, the rule can only be applied once per squirrel per turn.


--
You received this message because you are subscribed to the Google Groups "PuzzleScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puzzlescript...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Matt Slaybaugh

unread,
Nov 24, 2013, 10:03:37 AM11/24/13
to puzzle...@googlegroups.com, Matt Slaybaugh
Oh, thanks. I should have realized that.

And it wasn't clear to me from the documentation, but is there a rule for which direction takes precedence? Is it always above, then left, then right, then below?

Stephen Lavelle

unread,
Nov 24, 2013, 10:23:08 AM11/24/13
to Matt Slaybaugh, puzzle...@googlegroups.com
>is there a rule for which direction takes precedence? Is it always above, then left, then right, then below?

you can't rely on the internal ordering/precedence (though you can view it with verbose_logging (cf http://www.puzzlescript.net/documentation/prelude.html )  ). if it's super important to you, you should rewrite them all on separate lines as separate rules.

Connorses

unread,
May 18, 2015, 1:51:33 PM5/18/15
to puzzle...@googlegroups.com, matt.sl...@gmail.com
I thought it checked them in the order of up-down-left-right?
Reply all
Reply to author
Forward
0 new messages