title Robot Repairs 1.2
author Weeble
homepage www.twitter.com/weeble
run_rules_on_level_start
again_interval 0.05
key_repeat_interval 0.12
noaction

========
OBJECTS
========
Player
WHITE #dddddd #6666aa #666699 #666677 #3333aa
.111.
15051
10001
22222
3...3

SphereBlue
#7777ff #5555ee #3333dd #2e2ecc #2222bb #1d1daa #111199
.112.
10012
10013
62246
.666.

SphereRed
#ff7777 #ee5555 #dd3939 #cc2e2e #bb2222 #aa1d1d #991111
.112.
10012
10013
62246
.666.

SphereYellow
#ffff77 #eeee55 #dddd39 #cccc2e #bbbb22 #aaaa1d #999911
.112.
10012
10013
62246
.666.

SphereRight
RED
.....
.....
...00
.....
.....

SphereLeft
RED
.....
.....
00...
.....
.....

SphereUp
RED
..0..
..0..
.....
.....
.....

SphereDown
RED
.....
.....
.....
..0..
..0..

LaserOff
#205050 #1d4848 #154040 #103838 #0a3030 #052828 #330000
.011.
06001
14555
444..
55555

Laser
#205050 #1d4848 #154040 #103838 #0a3030 #052828 #ff0000
.011.
06001
14555
444..
55555

ProjectorOff
#205050 #1d4848 #154040 #103838 #0a3030 #052828 #333300
.011.
00001
16665
46664
55555

Projector
#205050 #1d4848 #154040 #103838 #0a3030 #052828 #ffff00
.011.
00001
16665
46664
55555

Beam
#ff0000
.....
00000
00000
.....
.....

YellowHologram
#ffff00 #ffff77
.1001
10010
0..00
0..01
1001.

Bridge
#ffff00 #ffff77
10001
0...0
0...0
0...0
10001


Floor
#505050 #484848 #404040 #383838 #303030 #282828
23234
23334
23334
23334
23434

BrokenFloor
#505050 #484848 #404040 #383838 #303030 #282828
23444
23233
24334
33344
23434

RedTarget
#404040 #303030 #aa1d1d #991010 #770808
11111
14340
13230
14340
10000

YellowTarget
#404040 #303030 #aaaa1d #999910 #777708
11111
14340
13230
14340
10000

BlueTarget
#404040 #303030 #1d1daa #101099 #080877
11111
14340
13230
14340
10000

TeleportDestOn
#404040 #303030 #1d1daa #5050bb #404099
11111
14140
11300
14040
10000

TeleportDestOff
#404040 #303030 #101050 #101040 #101030
11111
14140
11300
14040
10000

TeleportSourceOn
#404040 #303030 #1d1daa #5050bb #404099
11111
14340
13030
14340
10000

TeleportSourceOff
#404040 #303030 #101050 #101040 #101030
11111
14340
13030
14340
10000


Wall
#205050 #1d4848 #154040 #103838 #0a3030 #052828
00035
10335
11435
14445
55555

BrokenWall
#205050 #1d4848 #154040 #103838 #0a3030 #052828
.10..
3033.
11455
14545
55555


Studs
#505050 #303030 #404040 #383838
22221
20301
23331
20301
21111

Warning
#5500aa #303030 #404040 #383838 #000000 #777722 #666618
11111
44656
46564
65644
22222

Space1
BLACK WHITE
00001
00000
00010
01000
00000

Space2
BLACK WHITE
00000
01000
00000
00010
00000

(FakeBackground
BLACK)

=======
LEGEND
=======

(Floors)
. = Floor
: = BrokenFloor
1 = RedTarget
2 = YellowTarget
3 = BlueTarget
# = Studs
X = Warning
Q = Space1
Z = Space2
S = TeleportSourceOff
D = TeleportDestOff


% = Wall and Floor
$ = BrokenWall and Floor
R = SphereRed and Floor
Y = SphereYellow and Floor
B = SphereBlue and Floor
~ = LaserOff and Floor
& = ProjectorOff and Floor
(G = SphereGreen and Floor)
@ = Player and Floor

TeleportSource = TeleportSourceOff or TeleportSourceOn
TeleportDest = TeleportDestOff or TeleportDestOn
Teleport = TeleportSource or TeleportDest
Space = Space1 or Space2
Sphere = SphereRed or SphereYellow or SphereBlue
Mover = SphereRight or SphereLeft or SphereUp or SphereDown
Block = Wall or Studs or BrokenWall or YellowHologram or Laser or Projector or ProjectorOff or LaserOff
BlocksPlayer = Wall or BrokenWall or Warning
BlocksBeam = Wall or BrokenWall or YellowHologram or Sphere
Projection = YellowHologram or Bridge
Target = RedTarget or YellowTarget or BlueTarget
Background = Floor or Target or Studs or Warning or Space or BrokenFloor or Teleport
CanTeleport = Player or Sphere or YellowHologram
CanBlockTeleport = CanTeleport

=======
SOUNDS
=======

(Sphere MOVE 14946900)

sfx0 76218507
sfx1 14946900
sfx2 3233700
sfx3 97659702
sfx4 6750903 (whirr)
sfx5 30716303 (brr)
sfx6 95271309 (teleport)

(BrokenWall DESTROY 66942102 (kapow))
BrokenWall DESTROY 96418702 (drill)
YellowHologram MOVE 43208707 (peep)

(30051908 query)
================
COLLISIONLAYERS
================

Mover
Background
Bridge
Wall, BrokenWall, Player, Sphere, Laser, LaserOff, Projector, ProjectorOff, YellowHologram
Beam

======
RULES
======

(Start of turn clean-up.)

(Remove lasers. We'll recreate them later.)
[ Beam ] -> [ ]

(Replace movers with moving objects.)
[ Sphere SphereRight ] -> [ right Sphere ]
[ Sphere SphereLeft  ] -> [ left  Sphere ]
[ Sphere SphereUp    ] -> [ up    Sphere ]
[ Sphere SphereDown  ] -> [ down  Sphere ]

(Holograms can be pushed one cell at a time.)
[ > Player | YellowHologram no Space ] -> [ Player | > YellowHologram ]
[ > Player | YellowHologram Space Bridge ] -> [ Player | > YellowHologram Space Bridge ]

(Spheres can be pushed.)
[ > Player | Sphere ] -> [ Player | > Sphere ] sfx0

(Space without a bridge and other obstacles block player movement.)
[ > Player | Space no Bridge ] -> [ Player | Space ]
[ > Player | BlocksPlayer ] -> [ Player | BlocksPlayer ]

(Play a noise when a sphere comes to rest on its target.)
(First of all, when this happens due to a ricochet.)
[ > SphereRed RedTarget | Sphere ] -> [ SphereRed RedTarget | > Sphere ] sfx2 sfx1
[ > SphereYellow YellowTarget | Sphere ] -> [ SphereYellow YellowTarget | > Sphere ] sfx2 sfx1
[ > SphereBlue BlueTarget | Sphere ] -> [ SphereBlue BlueTarget | > Sphere ] sfx2 sfx1
[ > Sphere | Sphere ] -> [ Sphere | > Sphere ] sfx1

(Then, when it happens due to hitting an immovable obstacle.)
[ > SphereRed RedTarget | Block ] ->[ SphereRed RedTarget | Block ] sfx2
[ > SphereYellow YellowTarget | Block ] ->[ SphereYellow YellowTarget | Block ] sfx2
[ > SphereBlue BlueTarget | Block ] ->[ SphereBlue BlueTarget | Block ] sfx2
[ > Sphere | Block ] ->[ Sphere | Block ] sfx1

(Holograms can't be pushed into obstacles.)
[ > YellowHologram | Block ] -> [ YellowHologram | Block ]

(Keep spheres moving if they haven't been stopped.)
[ right Sphere ] -> [ right Sphere right SphereRight ] again
[ left  Sphere ] -> [ left  Sphere left  SphereLeft  ] again
[ up    Sphere ] -> [ up    Sphere up    SphereUp    ] again
[ down  Sphere ] -> [ down  sphere down  SphereDown  ] again

(Late rules.)

(Holograms turn into bridges over space.)
late [ Space YellowHologram no Bridge ] -> [ Space Bridge ] sfx5

(Blue cores power teleporters.)
late [ TeleportDestOff ] -> [ TeleportDestOn ]
late [ TeleportSourceOff ] -> [ TeleportSourceOn ]
late [ TeleportDestOn ] [ BlueTarget no SphereBlue ] -> [ TeleportDestOff ] [ BlueTarget ]
late [ TeleportSourceOn ] [ BlueTarget no SphereBlue ] -> [ TeleportSourceOff ] [ BlueTarget ]

(Yellow cores power holograms.)
late [ ProjectorOff ] -> [ Projector ]
late [ Projector ] [ YellowTarget no SphereYellow ] -> [ ProjectorOff ] [ YellowTarget ]

(If projectors are off, destroy all holograms.)
late [ ProjectorOff ] [ Projection ] -> [ ProjectorOff ] [] sfx4

( Use BrokenFloor to indicate a projector has already created a projection. )
late [ ProjectorOff BrokenFloor ] -> [ ProjectorOff Floor ]
late down [ Projector Floor | no Projection no Block no Sphere ] -> [ Projector BrokenFloor | YellowHologram ] sfx5
( This next rule prevents a blocked projected from creating a
  projection after the blockage is removed. I'm not sure if I
  want that behaviour or not.
late [ Projector Floor ] -> [ Projector BrokenFloor ] )

(Red cores power lasers.)
late [ LaserOff ] -> [ Laser ]
late [ Laser ] [ RedTarget no SphereRed ] -> [ LaserOff ] [ RedTarget ]

(Lasers shoot laser beams.)
late right [ Laser | no Beam no BlocksBeam ] -> [ Laser | Beam ]
late right [ Beam | no Beam no BlocksBeam ] -> [ Beam | Beam ]

(Laser beams kill robots.)
late [ Player Beam ] -> [ Beam ] sfx3

(Laser beams destroy broken walls.)
late right [ Beam | BrokenWall ] -> [ Beam | no BrokenWall BrokenFloor ] again
late right [ Laser | BrokenWall ] -> [ Laser | no BrokenWall BrokenFloor ] again

(Teleports teleport.)
late [ TeleportSourceOn Mover CanTeleport ] [ TeleportDestOn no CanBlockTeleport ] -> [ TeleportSourceOn ] [ TeleportDestOn Mover CanTeleport ] sfx6
late [ TeleportSourceOn CanTeleport ] [ TeleportDestOn no CanBlockTeleport ] -> [ TeleportSourceOn ] [ TeleportDestOn CanTeleport ] sfx6

==============
WINCONDITIONS
==============

all RedTarget on SphereRed
all YellowTarget on SphereYellow
all BlueTarget on SphereBlue
no Mover

=======
LEVELS
=======

message <begin program>
message 01. ROBOT shall return POWER CORES to SOCKETS

(Teaches player about pushing spheres, standing on
studs, and putting spheres on targets.)

%xxxxxxxx%
%########$
%#@.r...#%
%#......#%
%#..#.###%
%#......#%
%######.#%
%#1.....#%
$########%
$xxxxxxxx%

message 02. POWER CORES must be SEATED with CARE

(Teaches player that spheres must come to rest.)

ZQ%%##########%%QZ
QZ%##........##%ZQ
ZZ%#......%...#%ZQ
zq%#.%........#%QQ
zq%#.......%..#%ZQ
qq%#.@.%......#%ZZ
qz%######.#.###%ZQ
ZZ%%%#y..2..#%%%ZZ
QZ%%%########%%%QZ

message 03. All SOCKETS must have POWER CORES

(Teaches player about the Newton's cradle effect.)

%xxxxxxxxxxx%
%%%####%####%
%#%....%...#%
%#%....%...#%
%#b...3r...#%
%#%.###%##.#%
%#@.#%%%%#.#%
%#..#%qz%#.#%
%#..#%zz%#1#%
%####%zq%###%
%%%%%%qq%%%%%

message 04. ROBOT must not cross SAFETY BARRIERS

(First non-trivial puzzle. Introduces warning bars.)

%%#########%%
%.##.....##.%
%.#.......#.%
%.#.......#.%
%.%xxx%xxx%.%
%.%...%...%.%
%.%.3.%.1.%.%
%.%.r.%.b.%.%
%.%xxx%xxx%.%
%.#...#...#.%
%.#@r.#.b.#.%
%.##1.#.3##.%
%%#########%%

message 05. POWER CORES must match SOCKET color

(Another warning bars puzzle. Has a one-way lock.
Might be too easy.)

qqz%%%%%%%%%%%
zzq%##########
$$$%#..2##2..#
###%#..r##r..#
#@###........#
###%#........#
%%#%xxxxxxxxxx
##.%#........#
##b##........#
###%#..y##y..#
$%%%#..1##1..#
zqz%##########
zzq%%%%%%%%%%%

message 06. ROBOT is TIRELESS

(Player experiences the drawbacks of the Newton's
cradle effect.)

%%%%%%%%%%%
%#########%
%#...@...#%
%#.......#%
##.%..%..#%
#r..1%...#%
#...11...#%
#..%..%..#%
#........#%
#r...r####%
#######%%%%

message 07. ROBOT restores ORDER

(Homage to Ricochet Robots.)

zq%###########
qz%##.......%#
qq%#r.%......#
zq%#....%3...#
qz%#....%%...#
zz%#.....b...#
qq%#1....2...#
zq%#.%y%%%%%##
qz%#.@.#%xxxxx
qq%#####%%%%%%


message 08. BLUE POWER CORES operate TELEPORT PADS

(Introduces teleporting both spheres and the player.)

#####%qqqq%#####
#bsb#%qqzq%#.d.#
#.b.#%zzzq%#.1.#
#.r.#%zqzq%#.y.#
#...#%zqzz%#...#
#.3.#%qzqq%#.r.#
#...#%qzzq%#...#
#.3.#%zzqz%#.y.#
#.@.#%qqzz%#.1.#
#.3.#%qqzz%#...#
#####%qzzq%#####

message 09. ROBOT is EFFICIENT and RELIABLE

(Easy version of the teleport puzzle.)

%%%%%%%%%zqqzqqz%%%%%%%%%
%#######%zqqzqzz%#######%
%#r.r.r#%z%%%%%z%#..1..#%
%#..x..#%%%...%q%#.....#%
%#rxsx.#......%q%#1.d.1#%
%#..x..#%%%@b3%z%#.....#%
%#r...1#%z%%%%%z%#..1..#%
%#######%qqzzqqq%#######%
%%%%%%%%%qzqqqqz%%%%%%%%%


message 10. ROBOT is optimized to RESOLVE and REPAIR

(This level was *way* too hard to be level 4. Everyone
gave up when they got here. Revamped it with teleports
and moved it further in.)

q%%########%%
q%#1..1..1#.%
z%#.....s.#.%
q%#.......#.%
q%%xxxxxxx%.%
qz%......b%.%
zz%bd.....%.%
zq%...b...%.%
q%%xxxxxxx%.%
z%#.......#.%
z%#@r.r..r#.%
q%#3..3..3#.%
z%%########%%



message 11. YELLOW POWER CORES operate ENERGY PROJECTORS

(Introduces projectors, demonstrating utility of
holograms. The puzzle with the blue spheres is a
nice stand-alone puzzle, but for now players get
to solve it the "easy" way with a hologram.)

%%%%%%%%%%%%%%%%
%#r1...#%%#####%
%#r.1..#%%#b.b#%
%#r..1.#%%#...#%
%#%...%#%%#3.b#%
%#..&...%%#...#%
%#..@.........#%
%#%...%#%%#3.3#%
%#y...2#%%#...#%
%#2...y#%%#3.b#%
%#y...2#%%#####%
%%%%%%%%%%%%%%%%




message 12. ROBOT can install ENERGY CUBES as BRIDGES across the VOID

(Introduces use of holograms as bridges.)

zqz%%%%%%%qqz
zq%%.....%%zz
q%%%..#..%%%q
%%%%.#y#.%%%%
xxx%.&2&.%xxx
%%%%..#..%%%%
#..z.....z..#
#r.q.@...q.b#
#..z.....q..#
%%%q%3%1%q%%%
qqzq%%%%%zzqz


message 13. RED POWER CORES operate DANGEROUS LASERS

(Introduces laser.)

zzqq%#####%zzqz
qqqz%#.2..%%%%%
qzzq%#....%####
q%%%%#....x...#
%%3%%#.r..%..r#
%~........x...#
%%b###....%r.y#
%1........r...#
%%%%%%....%..r#
qzzqq%....x.@.#
qqzzz%####%####

message 14. DANGEROUS LASERS must be operated with GREAT CARE

(More lasers.)

zz%%%%%%xxx%%%%%%zz
zq%.............%qz
zq%####%%%%%####%qq
qq%#.r#%###$#..#%qz
%%%#..#%.3.$#..#%%%
%x%~..#$$$$$#..#%x%
%%%#.@#%.b.%#..#%%%
qz%#r.#%...%#..#%zq
qz%####%%%%%####%qz
zq%....#1xr#....%qz
qz%%xxx%%%%%xxx%%zq

message 15. ROBOT is FULLY AUTONOMOUS

(Uses holograms and lasers.)

(I don't like how linear this level is. You're
kind of forced into every step. You can't push
the red spheres sideways or they'd get stuck.
You can't push them down because you couldn't
get them up again. You have to start by pushing
the yellow sphere. At every stage you have a
tiny number of options.)

(It used to be the penultimate level. I've moved
it back to somewhere it seems a more appropriate
level of difficulty. I think that it's okay for
some levels to be quite linear, as long as it's
not several in a row. It's much better than a
level that's so open as to be impossible to
reason about.)

zqzqzq%%%%%%%zzqqqz
qzzqq%.#####.%qqzqz
qqzz%..r###r..%zqzq
zqq%....&%&....%qqz
zq%%1....&....1%%qq
q%%..#@......#..%%z
q%...%%%%%%%%%...%z
%%.....#y2y.#%...%%
%%...%..%%%..%.&.%%
z%%~.$$$$$$$$$.$$%z
zq%%###########%%zq
zqq%xxxx%%%xxxx%zqz


message 16. ROBOT can operate in ADVERSE CONDITIONS

(Hard version of 12 - one hologram, can't replace it.)

zqz%%%%%%%qqz
zq%%.....$%zz
q%%:..#..$%%q
%%$$.#y#.:$%%
x:::.$2$.::xx
%::$.&$%.$::$
#..z.....z..#
#r.q.@...q.b#
#..z.....q..#
%%%q%3%1%q%%%
qqzq%%%%%zzqz

message 17. ROBOT is RECALCULATING

(Hard version of 14 - can't turn off the laser, extra blue target.)

zz$$$$$$xxx$##$%%zz
zq%%::......::$%%qz
zq%##:#$%%%%#:##%qq
qq%#rr#$###$#..#%qz
%%%#..#%.3.$#..#%%%
%x%~...$$$$$...:$3%
%%%#.@#%.b.%#..#%%%
qz%#r.#%.b.%#..#%zq
qz%####%:::%##:#%qz
zq%::::$1:::....%qz
qz%%xxx$%%%%###%%zq

message 18. ROBOT is ANALYTIC and PRECISE

(Hard version of 09. Probably pushing the limits
of how much sphere shuffling the player will put up
with...)


%%%%%%%%%zqqzqqz$%%%%%%%%
%#######%zqqzqzz%#######%
%#ry..r#%z%%%$:q%#..1..#%
%#yrx..#%%%.&.$q$#..2..#%
%#.xsx.#......:q:#12d21#%
%#..xyr#%%%@b3$z$#..2..#%
%#b..ry#%z%%%%%q$#1.1..#%
%#######%qqzzqqz%#######%
%%%%%%%%%qzqqqqz%%%%%%%%%

message 19. ROBOT is IMPASSIVE in the face of DANGER

(Hard version of 11. This time you can't use the
hologram to help with the blue puzzle, and you
can't switch the hologram off and on again, so
you need to be clever about the red puzzle.)

%%%%%%%%%%%%%%%%
%#r1...#%%#####%
%#r.1..#%%#b.b#%
%#r..1.#%$#...#%
%#%...%#$$#3.b#%
%#..&..:::#...#%
$:.....::q::::#%
qz:::zzqqz#3:3#$
zzqzzq:#..#:.:#%
zqzq:@y#.$#3:b#%
zzq$:.2#$$#####%
qzq$$%%%%%%%%%%%


message 20. ROBOT REPAIRS

(Try to include everything for the finale. Hopefully
the player will understand the core of the puzzle and
plan out what they need to do to succeed. Also let's
hope that there isn't some ridiculously easy way to
do it...)


(This level used to be a fair bit larger. The puzzle
remains essentially the same, it's just less messy.
There are fewer yellow spheres, so hopefully they're
easier to reason about, but they're a bit harder to
get into position. The blue spheres are now bunched
up and a hologram projector is provided - this lets
the player focus on figuring out where to put the
blue spheres without also needing to worry about
whether it's even possible to do so. Each blue sphere
area is now a simple rectangle rather than a ragged
and confusing shape.)

(It could probably still be a bit more tight, but I'm
happier with it than I was before.)

%%%%%%%%%%%%%%%%%%%%%%%%%%%q
x#####%xxx################%%
x#..d#%xx######&&%%qz######%
~#...#%x#######qq.#.q######%
x#...######qq%%&&.#.z######%
x#...#..&.#q.#....#.q#.&..#%
%#...#....xz.#.&&%%qqx....#%
%#...#....xq.#.qq.#.zx....#%
%#..2#....xqz%%&&.#.qx....#%
x#...#....xq.#....#.qx....#%
x#.&.#b...xz.#.%%%%qqx..bb#%
~#...#....xz.#.@.b..zx.3bb#%
x#yyy#....#qs%%%%%%sq#..bb#%
x##########q###r1###z#####%%
%%%%%%%%%%%zqqzzqzzqq%%%%%%z

message OPERATIONS COMPLETE
message ROBOT awaits INSTRUCTIONS
message <end program>