-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.ps
More file actions
executable file
·106 lines (71 loc) · 2.41 KB
/
main.ps
File metadata and controls
executable file
·106 lines (71 loc) · 2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
%!PS-Adobe-2.0
% Nicolas Seriot
% 2024-03-23
% https://github.com/nst/PSChess
% https://seriot.ch/projects/pschess.html
% gs -DNOSAFER main.ps
/showpage {flushpage} def % comment to produce output files, and use:
% gs -DNOSAFER -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile="%d.pdf" main.ps
% gs -DNOSAFER -dBATCH -dNOPAUSE -sDEVICE=png16m -sOutputFile="%d.png" -r300 main.ps
% magick -delay 50 *.png pschess.gif
(drawing.ps) run
<< /PageSize [600 400] >> setpagedevice
%200 400 translate
/Courier findfont 12 scalefont setfont
32 740 moveto
NewGame
PrintBoardAndGameState
gsave
50 50 translate
64 array GameState (BOARD) get _highlightIndices_board_DrawBoard
grestore
showpage
{
/userInput 128 string def
(>) print flush
(%lineedit) (r) file userInput readline
pop % bool
token not { () } if
{
exch pop
dup length 4 eq {
dup
/s1 exch ( ) cvs def
/s2 exch ( ) cvs def
/fromCoord { s1 0 2 getinterval } def
/toCoord { s2 2 2 getinterval } def
fromCoord _c_IsValidCoordinate_b_ toCoord _c_IsValidCoordinate_b_ and not {
(-- BAD COMMAND) ==
gsave
190 150 moveto
(BAD COMMAND) show
grestore
exit
} if
GameState (BOARD) get fromCoord toCoord false _board_fc_tc_dry_Move_canMove_squaresStatus_msg_
/msg exch def
/validMoves exch def
/canMove exch def
/canMoveCode canMove{1}{2}ifelse def
PrintBoardAndGameState
validMoves _highlights_DrawBoard
showpage
exit
} if
clear
(Usage:) =
(h2h3 - moves h2 to h3) =
exit
} loop
GameState (CURRENT_PLAYER) get (black) eq {
10 dict begin
BlackAutoMoveAndCheckGameState_highlights_gameIsOver_
/gameIsOver exch def
/highlights exch def
PrintBoardAndGameState
highlights _highlights_DrawBoard
showpage
gameIsOver { quit } if
end
} if
} loop