Chess/Checkers Board

A very basic chess/checkers board with an ASCII art display. No game logic beyond the move command, which allows any move, is implemented.

Category: Games
Functions: add(), mid(), mod(), mul(), sub(), switch(), u(), v().
Compatibility: CobraMUSH, PennMUSH.

Instructions

Copy and paste the below code into a compatible MUSH or MUX.

MUSHCode for Chess/Checkers Board

@create chess game.
@lock chess game.==me
@Desc chess game.=This is a tabletop chessboard. Type "display" to see it. If you would like to play a game, "setup chess" or "setup checkers"%rto move, "pmove b1 c1" or somesuch...that would move the piece in b1 to c1. Please Page or @mail ShadowHawke with any suggestions.
@set chess game./Desc = no_command
&LINE chess game.=|--1----2----3----4----5----6----7----8--|
&CLEAR chess game.=@dolist a b c d e f g h=&line-## me=[v(genline##)]
&CHESS chess game.=@dolist C D E F=&line-## me=[v(genline##)] ##;@dolist a b g h=&line-## me=[v(chess-##)];:is set up for chess.
&TAKE chess game.=&line-[v(0)] me=[mid(v(line-[v(0)]),0,add(mul(sub(v(1),1),5),3))][mid(- -,mod(mul(ufun(me/letnum,v(0)),v(1)),2),1)][mid(v(line-[v(0)]),sub(mul(v(1),5),1),50)]
&DISPLAY chess game.=$display:@pemit v(#)=[v(line)];@dolist a b c d e f g h={@pemit v(#)=[v(genline##)]%r[v(line-##)]%r[v(genline##)]};@wait 0=@pemit v(#)=[v(line)]
&START chess game.=$setup *:@switch v(0)=chess,{@tr me/chess},checkers,{@tr me/checkers},@pemit v(#)=I don't know how to setup for [v(0)]}
&PUT chess game.=&line-[v(0)] me=[mid(v(line-[v(0)]),0,add(mul(sub(v(1),1),5),3))][v(2)][mid(v(line-[v(0)]),sub(mul(v(1),5),1),50)]
&LETNUM chess game.=[switch(v(0),A,1,B,2,C,3,D,4,E,5,F,6,G,7,H,8,#-1)]
&GENLINEA chess game.=| - - - - - - - - - - - -|
&GENLINEB chess game.=|- - - - - - - - - - - - |
&GENLINEC chess game.=| - - - - - - - - - - - -|
&GENLINED chess game.=|- - - - - - - - - - - - |
&GENLINEE chess game.=| - - - - - - - - - - - -|
&GENLINEF chess game.=|- - - - - - - - - - - - |
&GENLINEG chess game.=| - - - - - - - - - - - -|
&GENLINEH chess game.=|- - - - - - - - - - - - |
&CHESS-A chess game.=| R - N - B - Q - K - B - N - R -| A
&CHESS-B chess game.=|- P - P - P - P - P - P - P - P | B
&CHESS-G chess game.=| p - p - p - p - p - p - p - p -| G
&CHESS-H chess game.=|- r - n - b - q - k - b - n - r | H
&CHECK-A chess game.=| - X - - X - - X - - X -| A
&CHECK-B chess game.=|- X - - X - - X - - X - | B
&CHECK-C chess game.=| - X - - X - - X - - X -| C
&CHECK-F chess game.=|- O - - O - - O - - O - | F
&CHECK-G chess game.=| - O - - O - - O - - O -| G
&CHECK-H chess game.=|- O - - O - - O - - O - | H
&LINE-A chess game.=| R - N - B - Q - K - B - N - R -| A
&LINE-B chess game.=|- P - P - P - P - P - P - P - P | B
&LINE-C chess game.=| - - - - - - - - - - - -| C
&LINE-D chess game.=|- - - - - - - - - - - - | D
&LINE-E chess game.=| - - - - - - - - - - - -| E
&LINE-F chess game.=|- - - - - - - - - - - - | F
&LINE-G chess game.=| p - p - p - p - p - p - p - p -| G
&LINE-H chess game.=|- r - n - b - q - k - b - n - r | H
&CHECKERS chess game.=@dolist D E=&line-## me=[v(genline##)] ##;@dolist a b c f g h=&line-## me=[v(check-##)];:is set up for checkers.
&PMOVE chess game.=$pmove * *:@tr me/pmove2=[mid(v(0),0,1)],[mid(v(0),1,1)],[mid(v(1),0,1)],[mid(v(1),1,1)],[mid(v(line-[mid(v(0),0,1)]),sub(mul(mid(v(0),1,1),5),2),1)]
&PMOVE2 chess game.=@tr me/put=[v(2)],[v(3)],[v(4)];@wait 0=@tr me/take=[v(0)],[v(1)];@wait 0=@lemit Piece [v(4)] moved from [v(0)][v(1)] to [v(2)][v(3)]
@set chess game.=COMMANDS