2015-05-19 07:27:39 +03:00
|
|
|
:: :: ::
|
|
|
|
:::: /hook/core/acto/ape :: :: dependencies
|
|
|
|
:: :: ::
|
2015-05-21 02:54:49 +03:00
|
|
|
/? 310 :: arvo version
|
|
|
|
/- *sole, *octo :: structures
|
|
|
|
/+ sole, octo :: libraries
|
2015-05-19 07:27:39 +03:00
|
|
|
:: :: ::
|
2015-05-23 20:03:02 +03:00
|
|
|
:::: :: :: server
|
2015-05-19 07:27:39 +03:00
|
|
|
!: :: ::
|
2015-05-08 20:56:30 +03:00
|
|
|
=> |% :: arvo structures
|
2015-05-23 20:03:02 +03:00
|
|
|
++ axle ,[eye=face rem=(unit ship) gam=game] :: agent state
|
2015-05-08 20:56:30 +03:00
|
|
|
++ card $% [%diff lime] :: update
|
|
|
|
[%quit ~] :: cancel
|
|
|
|
[%peer wire dock path] :: subscribe
|
2015-05-21 02:54:49 +03:00
|
|
|
[%poke wire dock pear] :: send move
|
|
|
|
[%pull wire dock ~] :: unsubscribe
|
2015-05-08 20:56:30 +03:00
|
|
|
== ::
|
2015-05-26 05:15:08 +03:00
|
|
|
++ face (map bone sole-share) :: console state
|
2015-05-08 20:56:30 +03:00
|
|
|
++ lime $% [%sole-effect sole-effect] :: :sole update
|
2015-05-26 05:15:08 +03:00
|
|
|
[%octo-update (each game tape)] :: :octo update
|
2015-05-08 20:56:30 +03:00
|
|
|
== ::
|
|
|
|
++ move (pair bone card) :: cause and action
|
2015-05-23 20:03:02 +03:00
|
|
|
++ pear ,[%octo-move point] :: outgoing move
|
2015-05-21 02:54:49 +03:00
|
|
|
-- ::
|
|
|
|
=> |% :: historical state
|
|
|
|
++ axon $%([%1 axle] [%0 axle-0]) ::
|
|
|
|
++ axle-0 ,[eye=face gam=game-0] ::
|
|
|
|
++ game-0 ,[who=? box=board boo=board] ::
|
2015-05-08 20:56:30 +03:00
|
|
|
-- ::
|
|
|
|
=> |% :: parsers
|
|
|
|
++ colm (cook |=(a=@ (sub a '1')) (shim '1' '3')) :: row or column
|
|
|
|
++ come ;~(plug colm ;~(pfix fas colm)) :: coordinate
|
2015-05-21 02:54:49 +03:00
|
|
|
++ comb (pick come ;~(pfix sig (punt fed:ag))) :: all command input
|
2015-05-08 20:56:30 +03:00
|
|
|
++ cope |=(? ?:(+< (stag %| (cold ~ sig)) comb)) :: with wait mode
|
|
|
|
-- ::
|
2015-05-23 20:03:02 +03:00
|
|
|
|_ [hid=hide moz=(list move) %1 axle] :: per agent
|
2015-05-26 05:15:08 +03:00
|
|
|
++ ce :: per client
|
|
|
|
|_ from ::
|
|
|
|
:: :: ::
|
|
|
|
:::: :: :: boilerplate
|
|
|
|
:: :: ::
|
|
|
|
++ abet [(flop moz) +>(moz ~)] :: resolve core
|
|
|
|
++ dish |=(cad=card %_(+> moz [[ost cad] moz])) :: send move
|
|
|
|
++ emit |=(lime (dish %diff +<)) :: send update
|
|
|
|
++ flay |= [pre=path fun=$+(_. _+>)] :: broadcast
|
|
|
|
^+ +>
|
|
|
|
=+ [all=(pale hid (prix pre)) los=+>+<] ::
|
|
|
|
|- ^+ +>.^$ ?~ all +>.^$(+< los) ::
|
|
|
|
=> .(ost p.i.all, src p.q.i.all) ::
|
|
|
|
$(all t.all, +>.^$ (fun +>.^$)) ::
|
|
|
|
:: :: ::
|
|
|
|
:::: :: :: state machine
|
|
|
|
:: :: ::
|
|
|
|
++ fail ?:(soul (fect %bel ~) ~|(%invalid-move !!)) :: user error
|
|
|
|
++ fect |=(sole-effect (emit %sole-effect +<)) :: send to console
|
|
|
|
++ fact |=((each game tape) (emit %octo-update +<)) :: send to network
|
|
|
|
++ flap |= [net=$+(_. _+>) con=$+(_. _+>)] :: update all
|
|
|
|
=. +> (flay /sole con) (flay /octo net) ::
|
|
|
|
++ flet ~(. et (~(got by eye) ost)) :: existing console
|
|
|
|
++ fret ~(. et *sole-share) :: new console
|
2015-05-23 20:03:02 +03:00
|
|
|
++ here ~(. go src gam) :: game core
|
2015-05-26 05:15:08 +03:00
|
|
|
++ kick |= a=point :: try move
|
|
|
|
=^ dud gam ~(m at:here a) ::
|
|
|
|
?.(dud fail ?~(rem kind (send a))) ::
|
|
|
|
++ kind =+ res:here :: move result
|
|
|
|
?~(- wild (word:wild(gam new:here) ->)) ::
|
|
|
|
++ plan |= (unit ship) :: link/unlink
|
|
|
|
?~ +< wild:stop(gam *game) ::
|
|
|
|
?^(rem fail (link u.+<)) ::
|
|
|
|
++ plot |= (each point (unit ship)) :: apply command
|
|
|
|
?-(+<- & (kick +<+), | (plan +<+)) ::
|
|
|
|
++ send |= a=point ::
|
|
|
|
(dish poke/((like +.rem) %octo-move +<)) ::
|
|
|
|
++ soul =(%sole -:q:(~(got by sup.hid) ost)) :: is console
|
|
|
|
++ like |=(ship |*(* [/octo [+>+< %octo] +<])) :: message to friend
|
|
|
|
++ link |= ship :: subscribe to friend
|
|
|
|
^+ +>
|
|
|
|
(dish(rem `+<) peer/((like +<) /octo)) ::
|
|
|
|
++ lose ?^(rem . tame(gam out:here)) :: lost subscriber
|
|
|
|
++ meet ?^(rem . tame(gam inn:here)) :: gained subscriber
|
|
|
|
++ stop ?~(rem . (dish pull/((like +.rem) ~))) ::
|
|
|
|
++ tame %+ flap |=(_. (fact:+< &/gam)) :: light update
|
|
|
|
|=(_. abet:prom:flet:+<) ::
|
|
|
|
++ wild %+ flap |=(_. (fact:+< &/gam)) :: heavy update
|
|
|
|
|=(_. abet:prom:show:flet:+<) ::
|
|
|
|
++ word |= txt=tape %+ flap :: game message
|
|
|
|
|=(_+> (fact:+< |/txt)) ::
|
|
|
|
|=(_+> (fect:+< txt/txt)) ::
|
|
|
|
:: :: ::
|
|
|
|
:::: :: :: console logic
|
|
|
|
:: :: ::
|
|
|
|
++ et ::
|
|
|
|
|_ say=sole-share :: per console client
|
|
|
|
++ abet +>(eye (~(put by eye) ost say)) :: continue
|
|
|
|
++ amok +>(eye (~(del by eye) ost)) :: discontinue
|
|
|
|
++ apex =+(+> |.(+>(+> +<))) :: in context
|
|
|
|
++ beep (emit %bel ~) :: user error
|
|
|
|
++ emit |=(sole-effect (apex (fect +<))) :: local emit
|
|
|
|
++ cusp (cope !ept:here) :: parsing rule
|
|
|
|
++ delt |= cal=sole-change :: input line change
|
|
|
|
^+ +>+> ::
|
|
|
|
=^ cul say (remit:sole cal good) ::
|
|
|
|
?~ cul abet ::
|
|
|
|
abet:beep:(emit det/u.cul) ::
|
|
|
|
++ good |=((list ,@c) -:(rose (tufa +<) cusp)) :: valid input
|
|
|
|
++ make ^+ +>
|
|
|
|
=+ (rust (tufa buf.say) (punt comb)) :: apply command
|
|
|
|
?~ - abet:beep ::
|
|
|
|
?~ -> abet:show ::
|
|
|
|
(plot:abet:wipe ->+) ::
|
|
|
|
++ prom (emit %pro %& %octo stat) :: update prompt
|
|
|
|
++ rend (turn `wall`tab:here |=(tape txt/+<)) :: table print
|
|
|
|
++ show (emit %mor rend) :: update board
|
|
|
|
++ sole ~(. cs say) :: console core
|
|
|
|
++ work |= act=sole-action :: console input
|
|
|
|
^+ +>+>
|
|
|
|
?:(?=(%det -.act) (delt +.act) make) ::
|
|
|
|
++ stat ^- tape =+ ike=~[(icon who.gam)] :: status line
|
|
|
|
%- zing :~ ::
|
|
|
|
?~(rem "" "@{(scow %p u.rem)}") ::
|
|
|
|
?~(aud.gam "" vew:here) ::
|
|
|
|
?: !ept:here " ({ike}'s turn) " ::
|
|
|
|
": {ike} (row/col): " ::
|
|
|
|
== ::
|
|
|
|
++ wipe =^ cal say (transmit:sole set/~) :: clear line
|
|
|
|
(emit %det cal) ::
|
|
|
|
-- ::
|
|
|
|
:: :: ::
|
|
|
|
:::: :: :: handlers
|
|
|
|
:: :: ::
|
|
|
|
++ reap-octo :: linked to friend
|
|
|
|
|= [pax=path saw=(unit tang)] ::
|
|
|
|
?~ saw (word "linked to {<src>}") ::
|
|
|
|
(word(rem ~) "blocked by {<src>}") ::
|
|
|
|
++ coup-octo :: move acknowledge
|
|
|
|
|= [way=wire saw=(unit tang)] ::
|
|
|
|
?~(saw +> (word "move failed")) ::
|
|
|
|
++ diff-octo-game :: friend update
|
|
|
|
|= [way=wire gam=game] ::
|
|
|
|
?: =(^gam gam) +> ::
|
|
|
|
wild(gam gam) ::
|
|
|
|
++ peer-octo-net :: urbit peer
|
|
|
|
|= pax=path ::
|
|
|
|
tame:meet ::
|
|
|
|
++ peer-sole :: console subscribe
|
|
|
|
|= pax=path ::
|
|
|
|
tame:meet:abet:show:fret ::
|
|
|
|
++ poke-sole-action :: console input
|
|
|
|
|= act=sole-action ::
|
|
|
|
(work:flet act) ::
|
|
|
|
++ poke-octo-move ::
|
|
|
|
|= point ::
|
|
|
|
(kick +<) ::
|
|
|
|
++ prep |= [old=(unit ,[(list move) axon])] :: initialize
|
|
|
|
|
|
|
|
+>
|
|
|
|
++ pull-octo :: unsubscribe
|
|
|
|
|= pax=path ::
|
|
|
|
^+ +>
|
|
|
|
lose ::
|
|
|
|
++ pull-sole :: disconnect console
|
|
|
|
|= pax=path ::
|
|
|
|
^+ +>
|
|
|
|
amok:flet:lose ::
|
|
|
|
++ quit-octo :: unlinked by friend
|
|
|
|
|= way=wire
|
|
|
|
^+ +>
|
|
|
|
?~(rem +> (link +.rem)) ::
|
2015-05-08 20:56:30 +03:00
|
|
|
-- ::
|
2015-05-21 02:54:49 +03:00
|
|
|
:: :: ::
|
|
|
|
:::: :: :: handlers
|
|
|
|
:: :: ::
|
|
|
|
++ coup-octo :: move acknowledge
|
2015-05-26 05:15:08 +03:00
|
|
|
|= [then saw=(unit tang)] ::
|
|
|
|
abet:(~(coup-octo ce ost src) way saw) ::
|
2015-05-12 22:57:58 +03:00
|
|
|
++ diff-octo-game :: friend update
|
2015-05-26 05:15:08 +03:00
|
|
|
|= [then gam=game] ::
|
|
|
|
abet:(~(diff-octo-game ce ost src) way gam) ::
|
2015-05-23 20:03:02 +03:00
|
|
|
++ peer-octo-net :: urbit peer
|
2015-05-26 05:15:08 +03:00
|
|
|
|= [from path] ::
|
|
|
|
abet:(~(peer-octo-net ce +<-) +<+) ::
|
2015-05-08 20:56:30 +03:00
|
|
|
++ peer-sole :: console subscribe
|
2015-05-26 05:15:08 +03:00
|
|
|
|= [from path] ::
|
|
|
|
abet:(~(peer-sole ce +<-) +<+) ::
|
2015-05-08 20:56:30 +03:00
|
|
|
++ poke-sole-action :: console input
|
2015-05-26 05:15:08 +03:00
|
|
|
|= [from sole-action] ::
|
|
|
|
abet:(~(poke-sole-action ce +<-) +<+) ::
|
2015-05-19 07:27:39 +03:00
|
|
|
++ poke-octo-move ::
|
2015-05-26 05:15:08 +03:00
|
|
|
|= [from point] ::
|
|
|
|
abet:(~(poke-octo-move ce +<-) +<+) ::
|
|
|
|
++ prep |= [from (unit ,[(list move) axon])] :: initialize
|
|
|
|
abet:(~(prep ce +<-) +<+) ::
|
2015-05-23 20:03:02 +03:00
|
|
|
++ pull-octo :: unsubscribe
|
2015-05-26 05:15:08 +03:00
|
|
|
|= [from path] ::
|
|
|
|
abet:(~(pull-octo ce +<-) +<+) ::
|
2015-05-08 20:56:30 +03:00
|
|
|
++ pull-sole :: disconnect console
|
2015-05-26 05:15:08 +03:00
|
|
|
|= [from path] ::
|
|
|
|
abet:(~(pull-sole ce +<-) +<+) ::
|
2015-05-12 22:57:58 +03:00
|
|
|
++ quit-octo :: unlinked by friend
|
2015-05-26 05:15:08 +03:00
|
|
|
|= then ::
|
|
|
|
abet:(~(quit-octo ce ost src) way) ::
|
2015-05-12 22:57:58 +03:00
|
|
|
++ reap-octo :: linked to friend
|
2015-05-26 05:15:08 +03:00
|
|
|
|= [then saw=(unit tang)] ::
|
|
|
|
abet:(~(reap-octo ce ost src) way saw) ::
|
2015-05-08 20:56:30 +03:00
|
|
|
--
|