# # Utterly frivolous tic-tac-toe script # for Yakkey v1.0 # # $Id: xo.script,v 1.3 2001/04/27 09:01:20 jani Exp $ # $Revision: 1.3 $ # # by Jani Patokallio # Copyright 2001 the University of Tokyo # script.title= script.version=1.0 script.init= Pause
Yik-Yak-Yoe

a brutal example of YakScript abuse

(k) 2001 jani patokallio ; Set Xsign X ; Set Osign O ; Goto reset reset.init= Set X1 _ ; Set X2 _ ; Set X3 _ ; Set Y1 _ ; Set Y2 _ ; Set Y3 _ ; Set Z1 _ ; Set Z2 _ ; Set Z3 _ ; Set player $Xsign ; Goto row row.title=Player $player, select row: row.action=\ [ $X1 ] [ $X2 ] [ $X3 ] {Goto column X1 X2 X3 "$X1" "$X2" "$X3"} [ $Y1 ] [ $Y2 ] [ $Y3 ] {Goto column Y1 Y2 Y3 "$Y1" "$Y2" "$Y3"} [ $Z1 ] [ $Z2 ] [ $Z3 ] {Goto column Z1 Z2 Z3 "$Z1" "$Z2" "$Z3"} _BACK { Set message Game aborted... ; Goto end} # # $1,2,3 contain variable names for current row # $4,5,6 contain contents of said variables # (YakScript doesn't have double-dereferencing, ie. "$$1" won't work) # column.title=Player $player , select column: column.action= 1 [ $4 ] { "$4" != _ : Pause Can't do that! ; "$4" != _ : Goto row ; Set $1 $player; Goto turn } 2 [ $5 ] { "$5" != _ : Pause Can't do that! ; "$5" != _ : Goto row ; Set $2 $player ; Goto turn } 3 [ $6 ] { "$6" != _ : Pause Can't do that! ; "$6" != _ : Goto row ; Set $3 $player ; Goto turn } # # Yes, we have no arrays # (Everything quoted because playersigns have spaces...) # turn.init= "$X1" != _ && "$X1" == "$X2" && "$X2" == "$X3" : Goto win ; "$Y1" != _ && "$Y1" == "$Y2" && "$Y2" == "$Y3" : Goto win ; "$Z1" != _ && "$Z1" == "$Z2" && "$Z2" == "$Z3" : Goto win ; "$X1" != _ && "$X1" == "$Y1" && "$Y1" == "$Z1" : Goto win ; "$X2" != _ && "$X2" == "$Y2" && "$Y2" == "$Z2" : Goto win ; "$X3" != _ && "$X3" == "$Y3" && "$Y3" == "$Z3" : Goto win ; "$X1" != _ && "$X1" == "$Y2" && "$Y2" == "$Z3" : Goto win ; "$X3" != _ && "$X3" == "$Y2" && "$Y2" == "$Z1" : Goto win ; "$X1" != _ && "$X2" != _ && "$X3" != _ && \ "$Y1" != _ && "$Y2" != _ && "$Y3" != _ && \ "$Z1" != _ && "$Z2" != _ && "$Z3" != _ : Goto tie ; "$player" == "$Xsign" : Set player Z ; "$player" == "$Osign" : Set player $Xsign ; "$player" == Z : Set player $Osign ; Goto row win.init= Set message Player $player wins! ; Goto end ; tie.init= Set message Game tied... ; Goto end end.init= Pause \

$X1 $X2 $X3

$Y1 $Y2 $Y3

$Z1 $Z2 $Z3

$message end.title=Play again? end.action= Yes (Goto reset) No (Load index.script)