Simple pathfinding (proof of concept)

248 views
Skip to first unread message

piotrekli

unread,
Oct 7, 2017, 12:04:54 PM10/7/17
to PuzzleScript
This is a test of pathfinding I made about a year ago. Might be useful for monsters in adventure games. The code is under the WTFPL (http://www.wtfpl.net/about/).

Link:
http://www.puzzlescript.net/editor.html?hack=3495758ce4984291a3046393b7517ce6
Another version:
http://www.puzzlescript.net/editor.html?hack=35dc280a71c213b2dadf08aeb500f1d6

Skalmantas Šimėnas

unread,
Oct 8, 2017, 1:10:22 PM10/8/17
to PuzzleScript
Random is an interesting choice but your algorithm would also work very well with followers that try to retain their movement direction, which is nice.

Hand-E-Food

unread,
Oct 8, 2017, 5:57:10 PM10/8/17
to PuzzleScript
Looks good!

I feel the urge to share my version :-)

I wanted to make the move random if there were multiple equal paths, but you can't nest startloop commands.

Hand-E-Food

unread,
Oct 8, 2017, 6:05:55 PM10/8/17
to PuzzleScript

Jere Majava

unread,
Oct 9, 2017, 3:39:39 AM10/9/17
to PuzzleScript
Seems interesting but just can't wrap my head around this. Moving backgrounds always get me very confused.

Jere Majava

unread,
Oct 9, 2017, 5:36:40 AM10/9/17
to PuzzleScript
I've used similar method for most monsters here http://iotxt.net/gamlet/ (source: https://gist.github.com/jjmajava/6f200d8c878b43a28e8d) and in a few unfinished roguelikes.

Hand-E-Food

unread,
Oct 9, 2017, 6:05:29 AM10/9/17
to PuzzleScript
It's just temporary state.  There's a rule at the end to remove all movement from the background.  I treat up, down, left, right and action as conditional markers, and the Background is guaranteed to be in every cell.  It saves having to make additional objects and find layers for them.  Think of it as having a background layer containing six objects:

BackgroundX, BackgroundU, BackgroundD, BackgroundL, BackgroundR, BackgroundA

Hand-E-Food

unread,
Oct 9, 2017, 6:06:16 AM10/9/17
to PuzzleScript
Impressive!  I'm surprised my computer isn't struggling to play that.

Alan Hazelden

unread,
Oct 9, 2017, 6:17:27 AM10/9/17
to Hand-E-Food, PuzzleScript
I made some pathfinding code for my 868-HACK demake:

http://www.draknek.org/games/puzzlescript/8.68-HACK.php

That was back when there was a limit of 32 objects/6 layers, so it's probably not the clearest code though.

--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jere Majava

unread,
Oct 12, 2017, 6:11:26 AM10/12/17
to PuzzleScript
This moving background as a temporary state is really an eye opener for me. So far I've been using a ton of now unnecessary token objects for that. Thank you!

Here's my minimal pathfinding demo using background magic.

Hand-E-Food

unread,
Oct 12, 2017, 6:08:16 PM10/12/17
to PuzzleScript
I was excited to see you solve this without using startloop.  I put in some debugging and found it doesn't go directly to the player.  It makes a cool field effect however!


Skalmantas Šimėnas

unread,
Oct 13, 2017, 2:59:54 AM10/13/17
to PuzzleScript
Technically, that still uses a loop internally because puzzlescript expands that rule into a group of 4 rules that run on a loop (you can read more about this here).

Jere Majava

unread,
Oct 19, 2017, 4:39:10 AM10/19/17
to PuzzleScript
This is slightly better, but still some problems in the lower right sector. More than that, it creates a quite boring path.



Jere Majava

unread,
Nov 12, 2017, 4:09:52 AM11/12/17
to PuzzleScript


On Friday, October 13, 2017 at 1:08:16 AM UTC+3, Hand-E-Food wrote:

Hand-E-Food

unread,
Nov 12, 2017, 7:14:08 PM11/12/17
to PuzzleScript
Wow!  It took me a while to understand how that was deterministic.  Very nice!

One last improvement on line 101:

[ > Player Background ] -> [ > Player > Background ]
Reply all
Reply to author
Forward
0 new messages