Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add prelude/chess
  • Loading branch information
fizruk committed Feb 9, 2023
commit 2e8d5b709dd5d651f9e1d67891fb18f01d6be07f
30 changes: 16 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Compete in any or all of these categories:
<td><a href="prelude/guess1"><img src="prelude/guess1/guess1.png" width=100 height=100><br>guess1</a><br>(sm)</td>
<td><a href="prelude/pure-doors"><img src="prelude/pure-doors/pure-doors.png" width=100 height=100><br>pure-doors</a><br>(tristanC)</td>
<td><a href="prelude/fifteen"><img src="prelude/fifteen/fifteen.png" width=100 height=100><br>fifteen</a><br>(bradrn)</td>
<td><img src="base/chess/chess.gif" height=100><a href="base/chess"><br>chess</a><br>(fizruk)</td>
</tr></table>

## base (gam-10-80-hs-base)
Expand Down Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions play
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Binary file added prelude/chess/chess.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions prelude/chess/chess.hs
Original file line number Diff line number Diff line change
@@ -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"⋅⋅⋅⋅⋅⋅⋅⋅"++["♙♙♙♙♙♙♙♙","♖♘♗♕♔♗♘♖"]