[GAME] Find And Also Destroy (also example of breadth-first search)

45 views
Skip to first unread message

thelast19digitsofpi

unread,
Jul 12, 2022, 5:16:31 PM7/12/22
to PuzzleScript
A puzzle game that is kind of like Battleship meets... hmmm...
You get to see how far away the nearest ship is, but the challenge is that the ships have size 1.

There are 6 levels with different sizes and layouts.

https://www.puzzlescript.net/play.html?p=5dcd705010a0e0f6b98074259b82a173

(This game is interesting because I managed to figure out how to do breadth-first search in PuzzleScript. Here's the relevant code. I could have easily made it a lot simpler if I wasn't trying to give you the distance as well.)
(Scanning.)
[Action Player Sea] [ScansOne] -> [Action Player Sea BFS0] [ScansOne Decrease]

(Did you hit?)
[BFS0 Sub] [MinesOne] -> [SubDead] [MinesOne Decrease] sfx0

[Action Player BFS0] -> [Action Player BFS0] sfx1
[Action Player] -> [Player]

(Breadth-first search here we go!)
[BFS0 | Sea no BFS] -> [BFS0 | Sea BFS1]
[BFS1 Sub] [BFS0] -> [Sub] [Distance1]
[BFS1] [BFS0] -> [BFS1 DefinitelyNoSub] [BFS0]

[BFS1 | Sea no BFS] [BFS0] -> [BFS1 | Sea BFS2] [BFS0]
[BFS2 Sub] [BFS0] -> [Sub] [Distance2]
[BFS2] [BFS0] -> [BFS2 DefinitelyNoSub] [BFS0]
[BFS2 | Sea no BFS] [BFS0] -> [BFS2 | Sea BFS3] [BFS0]
[BFS3 Sub] [BFS0] -> [Sub] [Distance3]
[BFS3] [BFS0] -> [BFS3 DefinitelyNoSub] [BFS0]
[BFS3 | Sea no BFS] [BFS0] -> [BFS3 | Sea BFS4] [BFS0]
[BFS4 Sub] [BFS0] -> [Sub] [Distance4]
[BFS4] [BFS0] -> [BFS4 DefinitelyNoSub] [BFS0]
[BFS4 | Sea no BFS] [BFS0] -> [BFS4 | Sea BFS5] [BFS0]
[BFS5 Sub] [BFS0] -> [Sub] [Distance5]
[BFS5] [BFS0] -> [BFS5 DefinitelyNoSub] [BFS0]
[BFS5 | Sea no BFS] [BFS0] -> [BFS5 | Sea BFS6] [BFS0]
[BFS6 Sub] [BFS0] -> [Sub] [Distance6]
[BFS6] [BFS0] -> [BFS6 DefinitelyNoSub] [BFS0]
[BFS6 | Sea no BFS] [BFS0] -> [BFS6 | Sea BFS7] [BFS0]
[BFS7 Sub] [BFS0] -> [Sub] [Distance7]
[BFS7] [BFS0] -> [BFS7 DefinitelyNoSub] [BFS0]
[BFS7 | Sea no BFS] [BFS0] -> [BFS7 | Sea BFS8] [BFS0]
[BFS8 Sub] [BFS0] -> [Sub] [Distance8]
[BFS8] [BFS0] -> [BFS8 DefinitelyNoSub] [BFS0]
[BFS8 | Sea no BFS] [BFS0] -> [BFS8 | Sea BFS9] [BFS0]
[BFS9 Sub] [BFS0] -> [Sub] [Distance9]
[BFS9] [BFS0] -> [BFS9 DefinitelyNoSub] [BFS0]

(found nothing?!)
[BFS0] [BFS9] -> [Distance10OrMore] [] message No subs found in range 9. The closest one is at least 10 away but it might be farther.
[BFS0] -> [DefinitelyNoSub] message Nothing in this pond. The scan can't pass through the dry land.


(cleanup)
[BFS] -> []

Reply all
Reply to author
Forward
0 new messages