                                                                                                                                         
/maize  7 dec 66

3/	jmp brk

define	next a,b,c,d,e,f
	law . 4
	add i pdp
	dap . 1
	jmp i .
a	b	c	d	e	f
terminate

define winner a,b
	xct b 1000x[a]
terminate

siz=16000
q=200
qq=9s-[q>10-1]














































                >>13<<                                
/generate new maze

beg,	law 62
	lio (10
	arq
	jmp beg
	dra
	dio t
	rcr 9s
	xor t
	dac sed
	dac >>56<<ran
	jsp tex
	text .
turn on sense switch 1 for directions
>>40<<.
bgo,	law xtb
	dap . 2
	dzm bnt 17.
	dzm .
	idx .-1
	sas .-3
	jmp .-3
	clc
	dac ytb
	dac ytb 18.
	dac xtb
	dac xtb 18.
	law 2
	dac x
	law 18.
	dac y
	law drt 2
	dac drr
	law pdl
	dac pdp
	lac ran
	dac >>56<<sed
	law go


























                >>13<<                                
/main generation loop

sea,	dac i pdp	/return adr
	idx pdp
	lac ran
	rar 1
	xor (311071
	add (311071
	dac ran
	ral 6s
	ior ran
	dac t		/bit prob. = 3/4
	ral 6s
	ior (70000
	and t		/bit prob (bits 0,1,2) = 9/16
	and (770000
	dac i pdp
	law 7
	and ran
	adm i pdp	/low btts determine sequence of branch tries

/insert bit fr this location in table

ubt,	law bnt-1
	add y
	dap ub1
	law sht-1
	add x
	dap ub1 1
	lac i ub1 1
	xor (ril~rir
	dac ub2
ub1,	lio .
	xct .
	law 1
	ril 1
	rcr 1
ub2,	0
	dio i ub1

/display point at this location in maze

	law i 9
	add y
	mul (siz
	div (1
	hlt
	sub (siz>2
	dac t
	law i 9
	add x
	mul (siz
	div (1
	hlt
	sub (siz>2
	lio t
	dpy-i 300








                >>13<<                                
0lw,	next s1w,s2w,s3w,s1w,s2w,s3w
	sea 2
	sea 2
s1w,	law i drt 1	/look left
	add drr
	spa
	add (4
	add (drt
	dac ndr
	jdp chw		/check wall's presence
	jmp slw		/wall--skip left turn
	lac i pdp
	spa
	jmp lwl		/try to put up wall 9/16 of time
nlw,	jdp cho
	jmp olw		/if square is occupied
	jdp sup		/otherwise step intosquare and pushj
	jdp pup		/restore
slw,	next s2w,out,out,s3w,s3w,s2w		/ETC.
s2w,	lac drr
	dac ndr
	jdp chw
	jmp sfw
	lac i pdp
	ral 1
	sma		/more fwd moves than left or right
	jmp fwl
nfw,	jdp cho
	jmp ofw
	jdp sup
	jdp pup
sfw,	next s3w,s3w,s1w,out,s1w,out
s3w,	law i drt 3
	add drr
	spa
	add (4
	add (drt
	dac ndr
	jdp chw
	jmp srw
	lac i pdp
	ral 2s
	spa
	jmp rwl
nrw,	jdp cho
	jmp orw
	jdp sup
	jdp pup
srw,	next out,s1w,s2w,s2w,out,s1w
out,	law i 1
	adm pdp
	dap . 1
	jmp i .












                >>13<<                                
olw,	lac i pdp
	ral 3s
	spa
	jmp slw		/no wall 3/4 of time
lwl,	jdp scn		/try to put up wall
	jmp xlw		/don't put up wall
	jdp ins		/insert wall
	jmp slw
xlw,	jdp cho
	jmp slw
	jmp nlw 2

ofw,	lac i pdp
	ral 4s
	spa
	jmp sfw
fwl,	jdp scn
	jmp 0fw
	jdp ins
	jmp sfw
0fw,	jdp cho
	jmp sfw
	jmp nfw 2

orw,	lac i pdp
	ral 5s
	spa
	jmp srw
rwl,	jdp scn
	jmp 0rw
	jdp ins
	jmp srw
0rw,	jdp cho
	jmp srw
	jmp nrw 2






























                >>13<<                                
/pushj

sup,	0
	lio i ndr
	rcr 9s
	sar 9s
	adm y
	rcr 9s
	sar 9s
	adm x
	idx pdp
	lac drr
	dac i pdp
	idx pdp
	lac ndr
	dac drr
	lac sup
	jmp sea

/popj

pup,	0
	lac i drr
	cma>>05<<lia
	sar 9s
	adm x
	rcr 9s
	sar 9s
	adm y
	law i 1
	adm pdp
	lac i pdp
	dac drr
	law i 1
	adm pdp
	jmp i pup





























                >>13<<                                
/check for presence of wall

chw,	0
	sub (drt-chd-1
	dap chd
chd,	jmp .
	jmp cnw
	jmp cew
	jmp csw
cww,	law xtb-1
	jmp cew 1

csw,	law ytb-1
	jmp cnw 1

cew,	law xtb
	add x
	dap chg
	law sht-1
	add y
	jmp chg-1

cnw,	law ytb
	add y
	dap chg
	law sht-1
	add x
	dap chg 1
chg,	lio .
	xct .
	spi i
	idx chw
	jmp i chw

/check if next square has been entered

cho,	0
	lio i ndr
	rcr 9s
	sar 9s
	add y
	add (bnt-1
	dap ch2
	rcr 9s
	sar 9s
	add x
	add (sht-1
	dap ch2 1
ch2,	lio .
	xct .
	spi i
	idx cho
	jmp i cho












                >>13<<                                
/scan area bounded by walls and entered squares
/compute area, number of ways into area
/if area is 40-100, try to make only one access
/more if above or below this range

scn,	0
	lac x
	dac xs
	lac y
	dac ys
	dzm >>56<<nac
	dzm >>56<<are
	lac ndr
	dac sdr
sc2,	dac ndr
	jdp chw
	jmp sc3
	jdp cho
	jmp sc1
	lio i ndr
	rcr 9s
	sar 9s
	adm y
	rcr 9s
	sar 9s
	adm x
	law 1
sc4,	add ndr
	sub (drt
	sma
	sub (4
	spa
	add (4
	add (drt
	jmp sc2

sc5,	lac are
	sza i
	jmp ww0
	idx nac
sc3,	jdp aar
	law i 1
	jmp sc4

sc8,	lac nac
	sza i
	jmp sc7
	sas (1
	jmp ww0
	jmp ww3















                >>13<<                                
sc1,	lac i sdr
	cma
	sas i ndr
	jmp sc5
	lio i sdr
	rcr 9s
	sar 9s
	add ys
	sas y
	jmp sc5
	rcr 9s
	sar 9s
	add xs
	sas x
	jmp sc5
sc6,	jdp aar
	sub (200
	sma
	jmp sc9
	add (100
	sma
	cma
	add (100
	sal 3s
sc9,	sar 8s
	sza i
	jmp sc8
	add (1
	sub nac
	spq
	jmp ww0
sc7,	lac sdr
	dac ndr
	lac xs
	dac x
	lac ys
	dac y
	jmp i scn

/compute twice area enclosed

aar,	0
	lio i ndr
	rcr 9s
	sar 9s
	dac >>56<<scy
	rcr 9s
	sar 9s
	mul x
	lai
	ral 1
	adm are
	lac scy
	mul y
	lai
	ral 1
	adm are
	jmp i aar







                >>13<<                                
/count number of connected walls
/if greater than a random number less than the complexity,
/don't put in this wall

ww0,	lac ran
	rar 1
	xor (311071
	add (311071
	dac ran
	cli>>05<<swp
	div cmx
	hlt
	sil 5s
	lai
	sub cmx
	sma
	lio cmx
cmi=opr 100
	cmi>>05<<lai
	add (add
	dac >>56<<wlc
	idx pdp
	jsp wki
	jdp idl
	law i drt 1
	add ndr
	spa
	add (4
	add (drt
	dac ndr
	jsp wki
	law i 1
	adm pdp
	isp wlc
	jmp sc7
ww3,	idx scn
	jmp sc7

/increment location and turn left

idl,	0
	lio i ndr
	rcr 9s
	sar 9s
	adm y
	rcr 9s
	sar 9s
	adm x
	law i drt 1
	add ndr
	spa
	add (4
	add (drt
	dac ndr
	jmp i idl










                >>13<<                                
wlk,	dap wlx
	lac ndr
	jdp chw
	isp wlc
	jmp wlx
	lac chg
	sas (lio xtb
	sad (lio xtb 18.
	jmp wl1
	sas (lio ytb
	sad (lio ytb 18.
	jmp wl1
	lac wlx
wki,	dac i pdp
	idx pdp
	lac x
	dac i pdp
	idx pdp
	lac y
	dac i pdp
	idx pdp
	lac ndr
	dac i pdp
	idx pdp
	law i drt 3
	add ndr
	spa
	add (4
	add (drt
	dac ndr
	jsp wlk
	jdp idl
	jsp wlk
	jdp idl
	jsp wlk
	law i 4
	adm pdp
	dap wlp
wlp,	lac .
	dap wlx
	idx wlp
	lac i wlp
	dac x
	idx wlp
	lac i wlp
	dac y
	idx wlp
	lac i wlp
	dac ndr
wlx,	jmp .
wl1,	law 10
	adm wlc
	jmp wlx












                >>13<<                                
/insert wall

ins,	0
	lac ndr
	jdp chw
	nop
	lac (rir~ril
	xor i chg 1
	dac in1
	xct chg
	xct chg 1
	law 1
	ril 1
	rcr 1
in1,	0
	dio i chg
	rbt
	dio >>56<<but
	rir 7s
	spi i
	jmp i ins
in4,	jdp dar
	lac (-9xsiz siz>2
	dac po1
	law bnt
	dap db1
db1,	lio .
	lac (-9xsiz siz>2
	spi i
	jmp db2
	dio po2
	lio po1
	dpy-i 300
	lio po2
db2,	ril 1
	add (siz
	sas (18.xsiz-9xsiz siz>2
	jmp db1 2
	lac (siz
	adm po1
	idx db1
	sas (lio bnt 18.
	jmp db1
	rbt
	lai
	rir 6s
	spi i
	jmp i ins
	lio but
	dac but
	lai
	cma
	and but
	ral 3s
	spa
	jmp i ins
	jmp in4
	jmp i ins







                >>13<<                                
/maze display

go,	lio sed
	cla
	div (9
	hlt
	lai
	add (1
	sal q-1
	sub (q>2
	sal 5s
	dac xxp
	lio sed
	ril 9s
	cla
	div (9
	hlt
	lai
	add (1
	sal q-1
	sub (q>2
	sal 5s
	dac yyp
	law flexo  q4
	arq
	jmp .-2
	law 42
	lio (10
	arq
	jmp .-3
	jsp tex
	text .
maze number >>40<<.
	lac sed
	jdp dpt
	jsp tex
	text . complexity >>40<<.
	lac cmx
	jdp dpt
	szs i 10
	jmp rgo
























                >>13<<                                
	jsp tex	text /

starting at upper left of nonsense switches.

1  down  enable motion
2    up  perspective display
   down  plan display
3  down  display construction process
4  down  holds display of construction process after each wall is inserted
         until button 13 is pressed
5  down  display coordinates of block occupied by observer
7  down  displays running time (seconds)
8  down  set clock (adjust clock so both flags 5 and 6 are off)
9  down  replay this run after reaching winning block

bottom row

10 press to print distance travelled so far
11 press to restart this maze from the beginning
12 press to generate a new maze
13 press to step held display (switch 4)
14 press to set new complexity number
15 press to specify maze number
16 press to simulate a win
17 press to stop entire program
18 press to continue

knob 1 controls speed, left for reverse, right for forward
knob 2 is not used
knob 3 controls direction observer is heading,  knob points up for north
knob 4 controls magnification, left is wide-angle, right is telescopic

the goal is in the ne corner, you start randomly in the sw sector.>>40<</
rgo,	law brk		/rerun maze
	dap 3
	law but
	dap brn
rg1,	cac		/replay maze
	law pdl
	dac pdp
	lac xxp
	dac xxx
	lac yyp
	dac yyy
	lac (add
	dac dis
	dzm di2
	dzm >>56<<brc
	dzm v>>56<<th
	lac (lac
	dac >>56<<mag
	dzm tht
	dzm >>56<<prb
	lac (i
	dac hsp>>56<<
	asc 400
	cbs
	esm







                >>13<<                                
/update position and angle

pm2,	lac xxx
	sar 5s
	ior (1
	dac xco
	lac yyy
	sar 5s
	ior (1
	dac yco
	lac nmg
	dac mag
	lac nsn
	dac snt
	lac ncs
	dac cst
	law q
	add xco
	sar q-1
	dac >>56<<blx
	law q
	add yco
	sar q-1
	dac >>56<<bly
	lio but
	rir 2s
	spi
	jmp clb

/display coordinates

	lio but
	rir 5s
	spi i
	jmp pm5
	lio (300600
	jdp sdp
	lac blx
	lio (340600
	jdp sdp

/display running time

pm5,	lio but
	rir 3s
	spi i
	jmp pm3
	law 2437
	mul brc
	lio (300200
	jdp sdp














                >>13<<                                
/store history of this run

pm3,	law 18.
	mul blx
	div (1
	hlt
	add bly
	sad prb
	jmp pm4
	dac >>56<<prb
	lac 3
	sas (jmp brk
	jmp pm4
	lac (-add
	adm hsp
	lio i hsp
	sma
	ril 9s
	lac prb
	rcr 9s
	lac hsp
	spa
	rir 9s
	dio i hsp

/check for win

pm4,	clo
	law 18.x18. 18.
	sad prb
	jmp won
	lio but
	rir 8s
	spi i
	jmp pmz
	dzm bkc
	asc 100
	jdp dar
	jmp pm2


























                >>13<<                                
/perspective display setup

pmz,	lac (add-10
	dac >>56<<bkc
	asc 100
	lac snt
	div cst
	jmp sgc
cgs,	lio cst
	law mve
	spi
	law mvw
	dac dir
	dac odr
	law i q-1
	and yco
	spi
	add (q
	sub yco
	dac tyy
	dac ysv
	law i q-1
	and xco
	spi
	add (q
	sub xco
	dac txx
	dac xsv
	jmp pm1

sgc,	lio snt
	law mvn
	spi
	law mvs
	dac dir
	dac odr
	law i q-1
	and xco
	spi i
	add (q
	sub xco
	dac txx
	dac xsv
	law i q-1
	and yco
	spi
	add (q
	sub yco
	dac tyy
	dac ysv
pm1,	law i 10
	dac cnt
	law pm2
	dac luk
	lac (377777
	dac rit
	cma
	dac lft
	jmp lu1






                >>13<<                                
/main perspective display loop

/flag 2, 1 >>20<< display right edge of wall
/flag 4, 1 >>20<< display left edge of wall, or display winning wall
/flag 6, 1 >>20<< the scan of walls has advanced into the visible area
/            or into the area to the right of the left visiblity
/            limit extended behind the observer.
/            it indicates that when a point is to the left again,
/            the scan should stop.
/            the scan cannot possibly pass in front of the observer
/            without flag 6 going on.

luk,	0
	law drd 1
	lio xsv
	dio txx
	spi
	add (1
	lio ysv
	dio tyy
	spi
	add (2
	dap drd
	law q
drd,	jmp .
	jmp qd0
	jmp qd1
	jmp qd3
qd2,	cma
qd0,	adm xsv
	dac txx
	jmp lu1

qd3,	cma
qd1,	adm ysv
	dac tyy





























                >>13<<                                lu1,	clf 6
	stf 2
	jdp wall		/check for presence of wall
	jmp nw1		/no wall
lu2,	jdp cah
	jmp lu9		/point is behind to left
	jmp lu7		/point is to the right
	jmp lu9		/point is behind in the middle
			/or in fron to left
	dac rit		/point is in fron in middle
	law 5000
	szf i 2
	szf 4
	law 1000
	mul mag
	div lll
	jmp lu7
	dac vrt
	sal 1
	dac >>56<<vri
	law i 3
	dac >>56<<vrc
dlp,	lac hhh
	lio vrt
	dpy-i 300
	swp
	cma>>05<<swp
	dpy-i 300
	lac vri
	adm vrt
	szo
	jmp lu7
	szf i 2
	szf 4
	skp i
	jmp lu7
	isp vrc
	jmp dlp
lu7,	stf 6
	law i 10
	sad cnt
	szf 2
	jmp lu8
	jmp lu1 1
lu8,	clf 2
	jdp linc
	isp cnt
	jmp lu2
	jdp cdr
	lac txx
	dac xsv
	lac tyy
	dac ysv
	lac dir
	dac odr
	stf 4
	jmp lu2









                >>13<<                                
lu9,	szf 6
	jmp i luk
	jmp lu7 1

nw7,	jdp binc
	jdp cah
	jmp lu1
	jmp nw8
	jmp lu1
	jmp nw3

nw8,	stf 6
	jmp lu1 1

nw9,	szf i 6
	jmp nw7
	lac lft
	dac hhh
	jmp nw2

/no wall

nw1,	szf 6
	jdp binc
	jdp cah
	jmp nw9
	jmp nw8
	jmp nw9
nw3,	stf 6
	jdp wall
	jmp nw1 1


































                >>13<<                                
/display walls visible in this gap (recursively)

nw2,	lio rit
	idx pdp
	dio i pdp
	lio lft
	idx pdp
	dio i pdp
	lio dir
	idx pdp
	dio i pdp
	lio txx
	idx pdp
	dio i pdp
	lio tyy
	idx pdp
	dio i pdp
	lio luk
	idx pdp
	dio i pdp
	lac odr
	dac dir
	lac hhh
	dac lft
	jdp luk
	lac i pdp
	dac luk
	law i 5
	adm pdp
	lac i pdp
	dac rit
	idx pdp
	lac i pdp
	dac lft
	idx pdp
	lac i pdp
	dac dir
	idx pdp
	lac i pdp
	dac txx
	idx pdp
	lac i pdp
	dac tyy
	law i 5
	adm pdp
	law i 10
	dac cnt
	stf 6
	stf 2
	clf 4
	jmp lu2














                >>13<<                                
/check where point is in visual field

cah,	0
	lac txx
	mul cst
	scl qq
	dac xcs
	lac txx
	mul snt
	scl qq
	dac xsn
	lac tyy
	mul snt
	scl qq
	add xcs
	dac lll
	lac tyy
	mul cst
	scl qq
	cma
	add xsn
	mul mag
	scl 1
	div lll
	jmp sid
	dac hhh
	lia
	sub rit
	sma
	szo
	szo
	jmp ca1 2
	lai
	sub lft
	spq
	szo
	szo
	jmp ca1 1
ca1,	idx cah
	idx cah
	lac lll
	sma
	idx cah
	lai
	jmp i cah

sid,	xor lll
	spa
	jmp ca1 1
	jmp ca1 2















                >>13<<                                
/check for presence of wall

wall,	0
	clf 4
	lac dir
	sub (mvn-wad-1
	dap wad
wad,	jmp .
	jmp nwl
	jmp wwl
	jmp swl






















































                >>13<<                                
ewl,	lac txx
	add xco
	sar q-1
	add (sht
	dap waw 1
	lac tyy
	add yco
	sar q-1
	add (ytb
	jmp wa1

swl,	law 17
	add tyy
	add yco
	sar q-1
	add (sht-1
	dap waw 1
	lac xco
	add txx
	sar q-1
	add (xtb
	jmp wa1

wwl,	law 17
	add txx
	add xco
	sar q-1
	add (sht-1
	dap waw 1
	lac yco
	add tyy
	sar q-1
	add (ytb
	jmp wa1

nwl,	lac yco
	add tyy
	sar q-1
	add (sht
	dap waw 1
	lac xco
	add txx
	sar q-1
	add (xtb
wa1,	dap waw
	ral 9s
	add waw 1
	sas wi1
	sad win
	stf 4
waw,	lio .
	xct .
	spi
	idx wall
	jmp i wall










                >>13<<                                
/change direction

cdr,	0
	law i 10
	dac cnt
	lac dir
	sas (mvn
	sad (mvs
	jmp nos
	lia
	lac txx
	spa
	lio (mvs
	szm
	lio (mvn
	dio dir
	jmp i cdr

nos,	lia
	lac tyy
	spa
	lio (mve
	szm
	lio (mvw
	dio dir
	jmp i cdr

/little increment

linc,	0
	lac i dir
	lia
	sar 9s
	adm txx
	rcr 9s
	sar 9s
	adm tyy
	jmp i linc

/big increment

binc,	0
	lac i dir
	mul cnt
	scl 8s
	cma
	adm txx
	lac i dir
	rar 9s
	mul cnt
	scl 8s
	cma
	adm tyy
	jdp cdr
	jmp i binc










                >>13<<                                
/display plan view of wall

dmz,	0
	dap dmx
	lac i dmx
	dac dln 1
	dac dln 3
	law sht
	dap xsh
	lac (-9xsiz
	dac po1
dm0,	lac dmz
	dap gwd
	lac (-9xsiz
	dac po2
gwd,	lio .
xsh,	xct .
	spi i
	jmp dnl
	lio po2
	cla
dln,	add po1
	0
	dpy-i 200
	0
	add (siz>7
	sub po1
	sas (siz>7x10
	jmp dln
dnl,	lac (siz
	adm po2
	idx gwd
	sub dmz
	sas (lio 19.
	jmp gwd
	lac (siz
	adm po1
	idx xsh
	sas (xct sht 18.
	jmp dm0
	idx dmx
dmx,	jmp .























                >>13<<                                
dar,	0
	law xtb
	jda dmz
	swp
	law ytb
	jda dmz
	nop
	lac (-9xq
	add yco
	mul (siz
	div (q
	hlt
	dac tyy
	lac (-9xq
	add xco
	mul (siz
	div (q
	hlt
	lio tyy
	dpy-i 300
	dpy-i 300
	jmp i dar

/rat has reached goal
/display distance travelled

won,	dsc 100
	law i 400.
	dac inp
wo1,	jdp fds
	lio (000200
	jdp sdp
	law 2437
	mul brc
	lio (700200
	jdp sdp
	isp inp
	jmp wo1
	lio but
	rir 1
	spi i
	jmp rgo
	lac (add 7777
	dac >>56<<ghs
	law 777
	and 7777
	dac >>56<<plb
	lac (jmp brp
	sad 3
	jmp rg1
	dac 3
	law bu2
	dap brn
	lac hsp
	add (-add
	dac >>56<<ghe
	sas ghs
	jmp rg1
	jmp rgo






                >>13<<                                
/sequence break routines

brk,	sas (1
	jmp rbn
	isp bkc
	dsc 100
	ckn 200
	lai
	cma
	rar 8s
	sub (lac
	sub tht
	sar 3s
brx,	adm tht
	jda sin
	dac nsn
	lac tht
	jda cos
	dac ncs
	ckn 300
	lai
	rar 9s
	mul (340000
	add (37000
	dac >>56<<nmg
brn,	lio bu2>>56<<
	ril 9s
	spi i
	jmp re1
	ckn
	lai
	sub (200
	dac kn1
	spa
	cma
	clo
	adm dis
	szo
	idx di2
	lac kn1
	mul ncs
	jda brr
	xxx
	yyy
	xtb
	lac kn1
	mul nsn
	jda brr
	yyy
	xxx
	ytb
re1,	iot 610
	idx brc
	jmp ret











                >>13<<                                
/check for running into walls

brr,	0
	dap br1
	dap br2
	idx br2
	dap br3
	idx br3
br1,	lac i .
	lio brr
	spi i
	add (qx40
	and (1-qx40
	dac btm
	sar 5s
	sar q-1
br3,	add .
	dap gxy
br2,	lac i .
	sar 5s
	sar q-1
	add (sht
	dap gxy 1
gxy,	lio .
	xct .
	spi i
	jmp br4
	xct br1
	sub btm
	dac btm
	mul btm
	sub (20
	sma
	jmp br4
	add (20
	mul brr		/reduce velocity component if near wall
	scl 10000>q-1
	scl 4000>q-1
	jmp br4 1
br4,	lac brr
	adm i br1
	idx br3
	jmp i br3






















                >>13<<                                
/read buttons

rbn,	rbt
	lac but
	dio but
	cma
	and but
	dac >>56<<bon		/buttons turned on since last time
	sza i
	jmp ret
	spi
	jdp inf		/print distance
	lio bon
	ril 7s
	lac i 1
	sad (wat
	jmp brm
	lac 1
	spi
	jda sto		/stop
	jmp rb1
brm,	ril 1
	spi
	jmp sta		/start
rb1,	lio bon
	ril 6s
	spi
	jmp won
	rir 4s
	spi
	jmp bgo		/new maze
	rir 1
	spi
	jmp rgo		/restart this maze
	ril 3s
	spi
	jmp scm		/set complexity
	ril 1
	spi i
	jmp ret
smn,	jsp tex		/set maze number
	text /
type in maze no.  >>40<</
	jdp inp
	skp i
	jmp ret
	dac ran
	jmp bgo

scm,	jsp tex
	text /
type in complexity no.  (1<x<200)  >>40<</
	jdp inp
	dac cmx
ret,	lac 0
	lio 2
	jmp i 1








                >>13<<                                
/break routine for replay

brp,	sas (1
	jmp rbn
	lac yyy
	sar 5s
	add (q
	sar q-1
	dac btm
	lac xxx
	sar 5s
	add (q
	sar q-1
	mul (18.
	div (1
	hlt
	adm btm
	sas plb
	jmp bp2
	lac (-add
	adm ghs
	sad ghe
	jmp won
	lio i ghs
	sma
	ril 9s
	lai
	and (777
	dac plb
	sub (19.
	mul (1
	div (18.
	hlt
	sal q-1
	add (q>2
	sal 5s
	dac >>56<<nxx
	lai
	sal q-1
	add (q>2
	sal 5s
	dac >>56<<nyy























                >>13<<                                
/compute approx angle to center of next block and cause
/actual angle to approach this as a second order system

bp2,	lac nxx
	sub xxx
	dac >>56<<ndx
	lac nyy
	sub yyy
	dac >>56<<ndy
	div ndx
	jmp bp3
	sar 2s
	lio ndx
bp4,	spi
	add (add
	sub tht
	sub vth
	lia
	spa
	cma
	sub (i
	sar 9s
	and but
	dac bu>>56<<2
	lai
	sar 4s
	adm vth
	sar 5s
	jmp brx
bp3,	lac ndx
	div ndy
	hlt
	sar 2s
	cma
	add (lac
	lio ndy
	jmp bp4

/stop-start

sto,	0
	law (wat
	dap 1
	dsc 100
	jmp ret
sta,	lac sto
	dac 1
	asc 100
	jmp ret
















                >>13<<                                
/calibrate clock

clb,	lac 3
	dap clr
	law cl3
	dap 3
	asc 100
cl1,	law cs2
	dac 1
	law i 2000.>4 100.>4
	dac >>56<<clk
	iot 610
	jmp i 1

cs2,	isp clk
	jmp i cl1
	isp clk
	jmp clr
	jmp .-2

cl3,	sas (1
	jmp rbn
	lac clk
	clf 7
	sma
	stf 6
	add (100.>2
	spa
	stf 5
	lio but
	rir 2s
	spi
	jmp cl1
clr,	law .
	dap 3
	cbs
	jmp pm2




























                >>13<<                                
/print distance

inf,	0
	jsp tex
	text .
distance so far is >>40<<.
	jdp fds
	jdp dpt
	jsp tex
	text . blocks
>>40<<.
	jmp i inf

tfa,	jsp tex
	text .too far????
>>40<<.
	lac (add
	dac dis
	dzm di2
	jmp i inf

/decimal input routine

inp,	0
	clc
	dac inf
	tyi
	lai
	sad (77
	jmp ind
	sza i
	jmp inr
	sad (20
	cla
	sub (12
	sma
	jmp inr
	add (12
	rar 3s
	add inf
	ral 3s
	add inf
	adm inf
	jmp inp 3

ind,	lac inf
	sas (-0
	jmp i inp
inr,	idx inp
	jsp tex
	text /  input ignored.
>>40<</
	jmp i inp












                >>13<<                                
/find distance travelled

fds,	0
	lac (add
	xor dis
	lio di2
	swp
	scr 5s
	scr q-1
	swp
	sni
	jmp i fds

/text printer

tex,	dap txy
	lio i txy
	idx txy
	lac (607600
	rcl 6s
	sad (lai
txy,	jmp .
	sad . 2
	jmp tex 1
	swp
	tyo
	lia
	jmp txy-3

/decimal print

dpt,	0
	dac >>56<<dp1
	dzm >>56<<dp2
dpa,	dac >>56<<dp3
	cli>>05<<swp
	rcl 1
	div . 1
	12
	sas dp2
	jmp dpa
	sni
	lio (20
	tyo
	lac dp3
	dac dp2
	lac dp1
	sas dp2
	jmp dpa
	jmp i dpt















                >>13<<                                
/sine cosine routine
/max 260 usec

sin,	0
	dap six
	lac sin
	jmp coa
cos,	0
	dap six
	lac (200000
	add cos
	dac sin
coa,	add six-4
	ral 4s
	and sic 3
	add sic 2
	dap sob
	lac sin
sob,	jmp .
sic,	jdp sow
	jmp six
	sic
	14
	sub (200000
	jdp cow
	jmp six
	100000
	sub (400000
	jdp sow
	cma
six,	jmp .
	sub (600000
	jdp cow
	jmp six-1

sow,	0
	dac sin
	mul sin
	dac cos
	sar 2s
	sub (205044
	mul (237010
	mul cos
	scl 2s
	add (311040
	mul sin
	scl 2s
	jmp i sow
cow,	0
	dac sin
	mul sin
	scl 3s
	dac cos
	sar 4s
	sub (240573
	mul (373257
	mul cos
	add (377777
	jmp i cow






                >>13<<                                
/scope decimal print

dsz=4
sdp,	0
	dio >>56<<sdz
sda,	cli>>05<<swp
	scl 1
	div . 1
	12
	dac >>56<<sdy
	swp
	sal 1
	add (sdt
	dap sdc
	dzm >>56<<sdx
	law i 21
sdb,	dac >>56<<sdw
	dac >>56<<sdv
sdc,	lio .
	idx sdc
sdd,	lac sdx
	sub (400000 6007xdsz
	and (400000 7007xdsz
	spa
	add (377777 1001xdsz
	dac sdx
	ril 1
	spi i
	jmp sde
 	dio >>56<<sdu
	add sdz
	lia
	rar 9s
	dpy-i 200
	lio sdu
sde,	isp sdw
	jmp sdd
	law i 22
	sas sdv
	jmp sdb
	law i 6xdsz
	add sdz
	and (-1000
	dac sdz
	lac sdy
	sza
	jmp sda
	jmp i sdp

sdt,	175014	30137	/0
	27	360000	/1
	305215	31143	/2
	105014	31133	/3
	36100	217704	/4
	137114	631130	/5
	175114	231131	/6
	3610	620501	/7
	155114	231133	/8
	15114	231137	/9






                >>13<<                                
drt,	1
	1000
	-1
	-1000

xtb,
xtb 19./
ytb,
ytb 19./
bnt,	repeat 18.,	0

	cli
sht,	1s=0	repeat 9,	ril 1s	1s=1s 1s 1
	repeat 9,	rir 1s	1s=1s>2
	1s=1
	cli

t,	0
x,	0
y,	0
drr,	drt
xs,	0
ys,	0
ndr,	0
sdr,	0








































                >>13<<                                
cmx,	50.
wi1,	winner xtb 18.,sht 17.
win,	winner ytb 18.,sht 17.
xxx,	0
yyy,	0
xxp,	0
yyp,	0
xco,	0
yco,	0
dis,	0
di2,	0
kn1,	0
btm,	0
cnt,	0
txx,	0
tyy,	0
xsv,	0
ysv,	0
dir,	0
odr,	0
mvn,	q>10
mvw,	-q>10x1000
mvs,	-q>10
mve,	q>10x1000
rit,	377777
lft,	400000
vrt,	0
po1,	0
po2,	0
hhh,	0
lll,	0
tht,	0
ncs,	377777
nsn,	0
cst,	377777
snt,	0
xcs,	0
xsn,	0
pdp,	pdl-1

variables
constants

pdl,
start beg




















                >>13<<                                                     
