diff --git a/README.md b/README.md index 9fcca4b..7326b71 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,7 @@ Compete in any or all of these categories:
guess1

(sm)
pure-doors

(tristanC)
fifteen

(bradrn) +
chess

(fizruk) ## base (gam-10-80-hs-base) @@ -110,20 +111,21 @@ Most games will return here on exit (others will require CTRL-c). 1) prelude/guess1/guess1.hs 2) prelude/pure-doors/pure-doors.hs 3) prelude/fifteen/fifteen.hs - 4) base/timing/timing.hs - 5) base/shoot/shoot.hs - 6) base/log2048/log2048.hs - 7) base/rhythm/rhythm.hs - 8) hackage/guess2/guess2.hs - 9) hackage/wordle/wordle.hs -10) hackage/ski/ski.hs -11) hackage/guesscolor/guesscolor.hs -12) hackage/bulls-n-cows/bulls-n-cows.hs -13) hackage/hallway-to-hell/hallway-to-hell.hs -14) hackage/1234-hero/1234-hero.hs -15) hackage/crappy-flappy/crappy-flappy.hs -16) hackage/pong/pong.hs -17) Quit + 4) prelude/chess/chess.hs + 5) base/timing/timing.hs + 6) base/shoot/shoot.hs + 7) base/log2048/log2048.hs + 8) base/rhythm/rhythm.hs + 9) hackage/guess2/guess2.hs +10) hackage/wordle/wordle.hs +11) hackage/ski/ski.hs +12) hackage/guesscolor/guesscolor.hs +13) hackage/bulls-n-cows/bulls-n-cows.hs +14) hackage/hallway-to-hell/hallway-to-hell.hs +15) hackage/1234-hero/1234-hero.hs +16) hackage/crappy-flappy/crappy-flappy.hs +17) hackage/pong/pong.hs +18) Quit ** Enter a number to select, or press enter to see the list again: ``` If you don't have bash, cd into each game's directory and try running the game's .hs file. diff --git a/play b/play index a5d9c74..39fc35e 100755 --- a/play +++ b/play @@ -11,6 +11,7 @@ GAMES=( prelude/guess1/guess1.hs prelude/pure-doors/pure-doors.hs prelude/fifteen/fifteen.hs +prelude/chess/chess.hs base/timing/timing.hs base/shoot/shoot.hs base/log2048/log2048.hs diff --git a/prelude/chess/chess.gif b/prelude/chess/chess.gif new file mode 100644 index 0000000..a888af0 Binary files /dev/null and b/prelude/chess/chess.gif differ diff --git a/prelude/chess/chess.hs b/prelude/chess/chess.hs new file mode 100755 index 0000000..547a19f --- /dev/null +++ b/prelude/chess/chess.hs @@ -0,0 +1,11 @@ +#!/usr/bin/env stack +-- stack script --resolver=lts-20.10 +at [c,r] f = fmap reverse.traverse (\(j,row) -> traverse (\(i,p) -> if [i,j]==[c + ,r] then f p else pure p) (zip ['a'..] row)) . zip ['1'..].reverse +([fc,fr]>-[tc,tr])b=(head.at[fc,fr](pure.const '⋅').head.at + [tc,tr](pure.const(head(fst(at[fc,fr](flip(,)' '.pure) b)))))b +num b = l:h:(reverse.zipWith(\r s->(r:'|':s)++['|',r])['1'..].reverse)b++[h,l] + where l=" "++(fst<$>zip['a'..](head b))++" "; h=const '—'<$>l +run b = (putStrLn.unlines.num)b>>putStr "Enter move (e.g. e2-e4): ">>getLine>>= + \i->case i of {[x,y,'-',u,v]->run (([x,y]>-[u,v]) b); _ -> run b} +main=run$["♜♞♝♛♚♝♞♜","♟♟♟♟♟♟♟♟"]++replicate 4"⋅⋅⋅⋅⋅⋅⋅⋅"++["♙♙♙♙♙♙♙♙","♖♘♗♕♔♗♘♖"]