Skip to content

Instantly share code, notes, and snippets.

@pancelor
Created June 24, 2020 02:17
Show Gist options
  • Save pancelor/dadb67017af7ad7ec2c59135607f7096 to your computer and use it in GitHub Desktop.
Save pancelor/dadb67017af7ad7ec2c59135607f7096 to your computer and use it in GitHub Desktop.
Sock Friends (PuzzleScript Script)
Play this game by pasting the script in http://www.puzzlescript.net/editor.html
title Sock Friends
author pancelor
homepage www.twitter.com/pancelor
noaction
again_interval 0.05
run_rules_on_level_start
(verbose_logging)
========
OBJECTS
========
Background
lightgreen green
11111
01111
11101
11111
10111
UnmatchedSock
white blue gray
000..
111..
000..
00001
20001
MatchedSock
white red gray
000..
111..
000..
00001
20001
StringH0
black
.....
.....
0.0.0
.....
.....
StringH1
black
.....
.....
.0.0.
.....
.....
StringV0
black
..0..
.....
..0..
.....
..0..
StringV1
black
.....
..0..
.....
..0..
.....
mTooClose
gray yellow
1...1
...1.
..1..
.1...
1...1
mTooCloseR
gray yellow
1....
1....
1....
1....
1....
mTooCloseL
gray yellow
....1
....1
....1
....1
....1
mTooCloseU
gray yellow
.....
.....
.....
.....
11111
mTooCloseD
gray yellow
11111
.....
.....
.....
.....
Player
black orange white blue
.000.
.111.
22222
.333.
.3.3.
Crate
orange lightbrown
00000
01110
01110
01110
00000
Wall
brown darkbrown
00010
11111
01000
11111
00010
GlassCrate
orange white
00000
0.1.0
01..0
0..10
00000
Window
lightgray white
.1...
1....
....1
...1.
..1..
WindowBorderL
lightgray white
0....
0....
0....
0....
0....
WindowBorderR
lightgray white
....0
....0
....0
....0
....0
WindowBorderU
lightgray white
00000
.....
.....
.....
.....
WindowBorderD
lightgray white
.....
.....
.....
.....
00000
mNoWallR
yellow
mNoWallL
yellow
mNoWallU
yellow
mNoWallD
yellow
mWasMatched
red
mWasMatchedStationary
red
mDiagProbe
red
mDiagProbeTriggered
red
mStringProbeL0
red
mStringProbeL1
red
mStringProbeR0
red
mStringProbeR1
red
mStringProbeU0
red
mStringProbeU1
red
mStringProbeD0
red
mStringProbeD1
red
mStartup
red
mNotStartup
transparent
=======
LEGEND
=======
. = Background
# = Wall
@ = Player and mStartup
c = Crate
g = GlassCrate
w = Window
s = UnmatchedSock
(only here for level editing convenience:)
m = MatchedSock
& = Player
cSock = UnmatchedSock or MatchedSock
cPushable = cSock or Crate or Player or GlassCrate
cNoWall = mNoWallL or mNoWallR or mNoWallU or mNoWallD
cSockTestBlocker = Wall or Crate or Player or cSock
cTooClose = mTooClose or mTooCloseL or mTooCloseR or mTooCloseU or mTooCloseD
cStringH = StringH0 or StringH1
cStringV = StringV0 or StringV1
cString = cStringH or cStringV
cStringProbeH = mStringProbeL0 or mStringProbeL1 or mStringProbeR0 or mStringProbeR1
cStringProbeV = mStringProbeU0 or mStringProbeU1 or mStringProbeD0 or mStringProbeD1
cStringProbe = cStringProbeH or cStringProbeV
cWindowBorder = WindowBorderL or WindowBorderR or WindowBorderU or WindowBorderD
=======
SOUNDS
=======
Crate MOVE 36772507
cSock MOVE 41144707
cancel 87775304
sfx0 84149500
sfx1 22057104
EndLevel 3994900
================
COLLISIONLAYERS
================
(visual)
Background
Player, Wall, Window, Crate, GlassCrate, cSock
WindowBorderL
WindowBorderR
WindowBorderU
WindowBorderD
cStringH
cStringV
mTooClose
mTooCloseU
mTooCloseD
mTooCloseR
mTooCloseL
(non-visual)
mStartup, mNotStartup
mDiagProbe
mDiagProbeTriggered
mWasMatched
mWasMatchedStationary
cStringProbeH
cStringProbeV
cNoWall
======
RULES
======
(push stuff)
[ > cPushable | cPushable ] -> [ > cPushable | > cPushable ]
(socks wont move it it will unmatch them; track whether they were matched beforehand)
[ > MatchedSock ] -> [ > MatchedSock > mWasMatched ]
[ > mWasMatched | Wall ] -> [ mWasMatched | Wall ]
[ > mWasMatched | Window ] -> [ mWasMatched | Window ]
[ stationary MatchedSock ] -> [ MatchedSock mWasMatchedStationary ]
(
recalculate matched socks
shoot out NoWall marks from each sock; when they hit an unmatched sock it becomes matched
the 'again's let back-propagation happen
(only necessary for two cases b/c of the rule order, but it doesnt hurt to put it on all 4)
)
[cSock] -> [UnmatchedSock]
(Left)
late Left [cSock] -> [cSock mNoWallL]
late Left [mNoWallL | no cSockTestBlocker] -> [ | mNoWallL]
late Left [mNoWallL | cSock] -> [ mStringProbeR0 | MatchedSock]
(Right)
late Right [cSock] -> [cSock mNoWallR]
late Right [mNoWallR | no cSockTestBlocker] -> [ | mNoWallR]
late Right [mNoWallR | cSock] -> [ mStringProbeL0 | MatchedSock]
(Up)
late Up [cSock] -> [cSock mNoWallU]
late Up [mNoWallU | no cSockTestBlocker] -> [ | mNoWallU]
late Up [mNoWallU | cSock] -> [ mStringProbeD0 | MatchedSock]
(Down)
late Down [cSock] -> [cSock mNoWallD]
late Down [mNoWallD | no cSockTestBlocker] -> [ | mNoWallD]
late Down [mNoWallD | cSock] -> [ mStringProbeU0 | MatchedSock]
late [cNoWall] -> []
(notice unpairing)
late [mWasMatched no MatchedSock] -> cancel
(notice new pairs)
late [mNotStartup][MatchedSock no mWasMatched no mWasMatchedStationary] -> sfx0
late [mNotStartup][UnmatchedSock mWasMatchedStationary] -> sfx1
late [mWasMatched] -> []
late [mWasMatchedStationary] -> []
(draw window Borders)
late [cWindowBorder] -> []
late Left [Window | no Window] -> [Window WindowBorderL | ]
late Right [Window | no Window] -> [Window WindowBorderR | ]
late Up [Window | no Window] -> [Window WindowBorderU | ]
late Down [Window | no Window] -> [Window WindowBorderD | ]
(connect matched socks with String)
[cString] -> []
(Left)
late Left [mStringProbeL0 no cSockTestBlocker | ] -> [StringH0 | mStringProbeL1]
+late Left [mStringProbeL1 no cSockTestBlocker | ] -> [StringH1 | mStringProbeL0]
late Left [mStringProbeL0] -> []
late Left [mStringProbeL1] -> []
(Right)
late Right [mStringProbeR0 no cSockTestBlocker | ] -> [StringH0 | mStringProbeR1]
+late Right [mStringProbeR1 no cSockTestBlocker | ] -> [StringH1 | mStringProbeR0]
late Right [mStringProbeR0] -> []
late Right [mStringProbeR1] -> []
(Up)
late Up [mStringProbeU0 no cSockTestBlocker | ] -> [StringV0 | mStringProbeU1]
+late Up [mStringProbeU1 no cSockTestBlocker | ] -> [StringV1 | mStringProbeU0]
late Up [mStringProbeU0] -> []
late Up [mStringProbeU1] -> []
(Down)
late Down [mStringProbeD0 no cSockTestBlocker | ] -> [StringV0 | mStringProbeD1]
+late Down [mStringProbeD1 no cSockTestBlocker | ] -> [StringV1 | mStringProbeD0]
late Down [mStringProbeD0] -> []
late Down [mStringProbeD1] -> []
late [cStringProbe] -> []
(check for socks too close together)
late [cTooClose] -> []
(orthogonal)
late [cSock | cSock] -> [cSock mTooClose | cSock mTooClose]
(diagonal)
late Horizontal [cSock | ] -> [cSock | mDiagProbe]
late Vertical [mDiagProbe | cSock] -> [mDiagProbeTriggered mDiagProbe | cSock mTooClose]
late Horizontal [cSock | mDiagProbeTriggered] -> [cSock mTooClose | ]
late [mDiagProbe] -> []
late [mDiagProbeTriggered] -> []
(draw)
late Left [mTooClose | ] -> [mTooClose | mTooCloseL]
late Right [mTooClose | ] -> [mTooClose | mTooCloseR]
late Up [mTooClose | ] -> [mTooClose | mTooCloseU]
late Down [mTooClose | ] -> [mTooClose | mTooCloseD]
late [mStartup] -> [mNotStartup]
==============
WINCONDITIONS
==============
no UnmatchedSock
no cTooClose
=======
LEVELS
=======
(
##################
#........#.......#
#......@...s...s.#
#...s............#
#....c...#.......#
#.s..#...#...cs###
#.....s..#.s...#s#
#........#.....#s#
#wwww##....#######
#................#
#..w..w..........#
##.www###........#
#s..wwws#........#
##################
)
message 1/n: socks want to be matched
.......#####
########...#
#....###.s.#
#.@.s#.....#
#s...#s....#
###....#####
..######....
message 1/n: socks don't have object permanence, yet
.....###.....
...###.###...
####s...s####
#s.........s#
###s..c..s###
..####@####..
.....###.....
(
##############
#########..s##
###.....#s...#
#.c...#c.....#
#.#...#c##.###
#@#..s......s#
###...########
##############
)
message 1/n: socks don't want to be alone
#############
##..@.##...s#
#..##.#...###
#.###s..s..##
#.#...#.....#
#.#s###..##.#
#...#.......#
#############
.#######...
.#@....#...
.###.s.####
..#.....s.#
..#.....#.#
###s#...s.#
#s.....####
####.....#.
...#....s#.
...###...#.
.....#####.
#######..
#s....#..
###.c.#..
..#...#..
..#s.s#..
..#...#..
..#.@.###
..#....s#
..#######
message 1/n: animals with three feet need matching socks too
....#####..
#####...#..
#..##.s.#..
#@.##...#..
#...##.####
##.s......#
.#..#...#.#
.#..#...s.#
.##########
.....#####
...###..s#
####...#.#
#........#
#.s#...#.#
#.@#.s...#
##########
....#####..
#####...#..
#..##.s.#..
#@.##...#..
#...##.####
##.s....c.#
.#..#...#.#
.#..#...s.#
.##########
message 1/n: socks need some personal space
...#####
####.s.#
#@##...#
#.#....#
#.s.s..#
##....##
.######.
#####......
#@..#######
##s.#.....#
#..##...s.#
#..s....#.#
#####.....#
....#######
######.
#s...#.
##...#.
.#s..#.
.#.@.#.
.#..s#.
.#...##
.#...s#
.######
...#####.
...#...#.
####.s.##
#.@#....#
#..##.#.#
#.s.....#
####..###
...#...s#
...######
..######.
..#..s.#.
..#....#.
..#....#.
#####.##.
#...#.#..
#.s...###
####....#
...#@..s#
...######
message 1/n: socks like windows
.#########
.#.......#
.#.s.###.#
.#...#...#
.#...w.s.#
.#.@.w...#
##...w.s.#
#s...#...#
##########
.##########.
##........##
#..#.sc.#..#
#.sw....ws.#
#..w....w..#
#..w....w..#
#..w.@..w..#
###w....####
..###....s#.
....#######.
###########
#.s.......#
#...##...s#
#.@.#.....#
###s..s.###
#...#...#..
#s..#####..
#...#......
#####......
.#########
.#.......#
.#.s.###.#
.#...w...#
.#...w.s.#
.#.@.w...#
##...w.s.#
#s...#...#
##########
message 1/n: socks like glass crates
(are glass crates useful design elements? idk)
######......
#....#######
#.@.g##....#
#..sc.....s#
###..#..####
..#s##..#...
..###.s.#...
....#...#...
....#####...
..######..
..#.@..#..
..#swws#..
..#cwwg#..
..#s..s#..
..#.ww.#..
..#.ww.#..
..#....#..
..#....#..
..#....###
..#.....s#
###....###
#s..####..
#####.....
...############
####..........#
#...........s.#
#........@....#
#...s.s.......#
#.............#
#wwwwwwwwwwwwww
#s#s.s#s.s#s.s#
###############
message 1/n: template
############
#..........#
#.@........#
#..........#
#..........#
#..........#
#..........#
#..........#
############
(not really starbattle - 1-star rows are allowed and 3 star rows are allowed. fine?)
(
todo
find more puzzles w/ current mechanics
more mechanics?
push socks into boxes (how to unwrap?)
teleporters
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment