Debian Codegraph @

src/thots

raw
1 ================================================================================
2 DONE
3 ================================================================================
4
5 * Maintaining game state
6 The problem is, what_next is getting tweaked everywhere. Everything
7 that is supposed to be done when a state change might not be taking
8 place everywhere. Perhaps what I should do is set an API to tweak the
9 state, perhaps set_state()/get_state() functions would be in order.
10
11 * Create themes capability. Instead of having game pieces hard coded in the
12 program, have various theme files for the user to choose from. Make
13 this selectable and changeable at runtime without hosing the game state.
14
15 * Where to store the .gamazons file
16 I noticed gnome-chess stored the user config file in the .gnome
17 directory. Perhaps there's a standard location for gnome's config files
18 that I can retreive via some gnome function call.
19
20 * Generate the moves made list
21 I've got that nice fancy window taking up precious real estate. I might
22 as well use it for what it was for.
23
24 * Install icons and menu features when game is installed. gnome chess created a
25 desktop file in /usr/local/share/gnome/apps. I'm not exactly sure how
26 to put the item in the game menu yet.
27
28 * Redo board drawing method
29 Instead of generating squares and filling them in with squares, lets use
30 pngs of squares and place them on the board. It might be useful to
31 store pointers to each square img in an array to allow easy access.
32 Once the tiles are placed on the board, then draw the grid on top of it.
33 This will make things much easier to replace board colors at will. I
34 could make options that let people choose tiles & pieces. Note: Created
35 theme capability so people can load new board theme on demand.
36
37
38 * Keeping up with option/game changes
39 Some options may change during the middle of the game. For example, the
40 autocomplete would make both players computer opponents. The network
41 stuff wouldn't be able to change. Each time the back end has to use one
42 of these changeable options, it should read it directly from the source.
43
44 But if we had a setup mode, the user could switch off game playing, configure
45 the board, and reenter game mode. To accomplish this, I'd need to change game
46 recognition from a linear model (W moved this queen here, so unmark the src
47 and mark the dest as the WQ), to a discover mode (look at all the squares on
48 the board and see what is on each). That's not very efficient for most things,
49 so perhaps just making a " discover_board" function that can be called when
50 exiting setup mode.
51
52
53 * Create a help file
54 Gnome uses HTML files for help stuff. Make a nice page that explains
55 the rules and what the buttons are for. In general, they should be
56 installed in /usr/local/share/gnome/help/gamazons/. Or I maybe
57 (PREFIX)/share/gnome/help/gamazons is more accurate.
58
59 * Redo
60 This is completely useless. If an undo has been done a couple of times,
61 and a different move has been made, Redoing by moving up a state in the
62 state array would completely void the different move that just took
63 place. If a user Undos once, he can just make the same move again if he
64 really wants. This just looks like it would create more bugs and not
65 add any useful functionality.
66
67 * Undo/Redo menu
68 There's already a convenient Undo button on the game board. Having two
69 separate ways to access this feature is unnecessary and bug-prone. I'd
70 have to make sure that whenever one is disabled, the other is disabled
71 too. Just dump the menu options, it's not very useful.
72
73 * Handling Interrupts
74 move_ai() should call a function to disable certain event handling instead of
75 just having a silly global variable. For instance, it could gray out the
76 Auto Finish button so the user knows it's not going to do anything when he
77 presses it. Perhaps the 'Force Move' button should be greyed out until the AI
78 is thinking, or since Force Move & Auto Finish are mutually exclusive, it would
79 be cool to have the button switch labels depending on the state of the game.
80
81 gtk_button_set_label(GtkButton *button, const gchar *label);
82 gtk_widget_set_sensitive (GtkWidget *widget, gboolean sensitive);
83 time = lookup_widget(PlayerSettingsWindow, "TimeSpinner");
84
85 * Have a popup declaring the winner
86 * Computer moving queens:
87 Instead of having the queens just pop around on the board when the
88 computer is moving, the queen should slide so the human can see what
89 piece is moving. I should be able to do some kind of move, maybe one
90 pixel at a time. Just calculate the origin and the destination, and
91 they _should_ just be straight diagonal (increment x coord by 1,
92 increment y coord by 1, draw), or horiz or vert. If moving by 1 is too
93 slow, we could make it 2 or whatever.
94
95 * Remembering values:
96 I need to store user options in a .gamazons file. When the user presses
97 OK in the player preferences, the values should be stored in this file
98 as well as in the global options struct. Then, init_engine() should read
99 in the values from a file (if it exists).
100
101 * Website requirements:
102 Explain how I verified that my program works
103 Explain what it takes to compile and run the program
104 Requires Gnome2
105 tweak a header file to compile amazons instead of gamazons
106 Post source code
107 Include a copy of the GPL w/ the source
108 Explain what it takes to run the program and how to use it
109
110 * Keeping the GUI & engine in sync
111 Currently, amazons has a state stucture that is local to main and passed
112 around wherever deemed necessary. Gamazons needs access to this, so
113 maybe I should make it global. I can still make a pointer to the global
114 and pass that around so I don't have to mess around with all the
115 function prototypes.
116
117 I need to create some coordinate conversion routines though, since 0,0
118 is in the bottom left for amazons, and top left for gamazons.
119
120 I also need to find a way to let the engine know when it's the AI's turn
121 to move. I may need to take out it's ability to think during its
122 opponent's turn for this to work properly.
123
124 I currently keep track of game state on the GUI side as well as on the
125 engine side. Should I dump the gui state and focus on the engine state?
126 Or is the convenience of not having to convert coordinates every time I
127 need to use one worth the inconvenience of keeping both in sync during
128 every change? -- Ugh, keep two, just keep them in sync.
129
130 * User input while the AI is thinking...
131 I should set a flag at the beginning of move_ai() that sez the computer
132 is thinking. Then at the beginning of all callbacks, I should check to
133 see if the AI is preparing to move and ignore all user input until it's
134 safe. While I'm at it, I should also make a check that if it is a human
135 player who's turn it is to move, that the human is moving his own
136 pieces. ie, if it's white's turn, he shouldn't be able to pick up black
137 pieces.
138
139 * Playing the game
140 Once the board is drawn and all the signals are registered, call a
141 function that checks if the first player is the AI or human. If it's
142 the AI, start the searching process for the next move. If it's a human,
143 just fall out of the function and don't do anything until the human
144 makes the first move (or maybe I could start the thinking process while
145 the human thinks also. However, that may be more complicated and I
146 should start small and work into that one). Then at the end of
147 processing the move signal (perhaps at the end of the fire_arrow
148 callback), I could check if the next move is done by human or AI.
149
150 I'll probably have two different functions for processing human moves
151 and AI moves, so I'd better make sure both work.
152
153 * Text mode vs GUI mode
154 I would like to maintain both versions, as each one has its place.
155 Everything that's text dependent should be bracketed with
156 #ifndef GAMAZONS, and stuff that's GUI dependent should be bracketed
157 with #ifdef GAMAZONS.
158
159 * handling options:
160 Instead of having several dozen global variables, each covering a
161 different option, I could make one big structure, covering all options.
162 Then I can create sub structs for network, players, etc...
163
164 * Drawing the board
165 it looks like I can use gnome_canvas_item_move to move a queen already placed
166 on the board. Perhaps I should draw the board initially, registering all the
167 callbacks with them, etc... and then just use that to move them. But then what
168 does the draw_board function do? gnome-chess called it all the time.
169
170 looks like gnome chess just used board_update to see if any pieces were taken
171 and deletes them if they are. I don't know if I need to draw the board after
172 the initial draw.
173
174 * Text looks messed up with custom fonts & fixed game board size
175 On Michael's computer, the game looked pretty screwy. I dunno what
176 font settings he used, but it made it look pretty messed up.
177 Unfortunately, my board is designed to be precisely the size it is. The
178 user doesn't have the ability to resize the game, board or pieces.
179 Unfortunately, this means people with high resolutions can't make the
180 board any bigger and people with low resolutions can't make it any
181 smaller. To change this, I'd need to learn how to scale the pieces, the
182 game board, and redo all the calculations which determine where pieces
183 are and where to move them to. If this were fixed, people with
184 different fonts could resize the board so it looked normal to them.
185 NOTE: Possibly fixed by just making more space for text
186
187 ================================================================================
188 TODO
189 ================================================================================
190 * Showing the latest square fired on:
191 The square the AI (or human) fired it's arrow on could be a different color
192 or shade until the next move starts.
193
194 * Undo
195 Instead of having a straight state struct, maybe I should have an array
196 of 100 of them. Then I could include a current move state and a max move
197 state so I could skip forward and backward.
198
199 Hmm, should I keep 100 of both states? or just keep all those states on
200 the engine side, and use the GUI state only for the current state of the
201 board? I'm currently inclined to just have the array on the engine
202 side.
203
204 What should Undo do? If a human player has moved a piece but not fired
205 yet, undo should just move the piece back. In this case, the engine
206 wouldn't need to be notified because the move isn't registered to the
207 engine until the arrow is fired. If the human is playing an AI, the
208 Undo should go back to the last human opponent.
209
210 When can Undo be used? Once autofinish has started, Undo won't be able
211 to find a human opponent. So it should be disabled once autofinish
212 starts. I don't want the AI interrupted by Undo once it has started
213 moving, so it should be disabled once move_ai() starts, and can be
214 renabled at the end.
215
216 * Have AI verify legality of Human move? Have GUI verify legality of AI move
217 Would it be useful to, when registering a human move w/ AI for it to
218 verify the move was legal? How about the GUI verifying an AI move is
219 legal? Having these checks might catch inconsistencies in the game
220 design, and perhaps end the game gracefully, warning the user a bug has
221 just occured. When this happens, I could dump the GUI state & AI state
222 to a text file, along with the offending move attempt to enhance
223 debugging.
224
225 * Different difficulty levels & Separate AI settings for each player
226 I want to create different difficulty levels for the AI player.
227 Starting with 0 = random and moving up to 10 or so, adding one more
228 heuristic at each level.
229
230 But then I'd like to separate the AI level, time, width, and TT. That
231 way I can pit one player up against the other without them "cheating" by
232 knowing what the other player will do.
233
234 * Have a preview pane for different themes.
235 * Make option to just see game board
236
237
238
239 ================================================================================
240 FIXED BUGS
241 ================================================================================
242 Black was set for a long run. I shortened the think time. Then I hit force
243 move. I think on black's next move he gained an extra queen and walked right
244 over a queen & wall. RESULT: Black suddenly had 5 amazons instead of 4.
245 SOLUTION: when hitting 'OK', it called move_ai(). I added a global flag
246 ' moving_ai' that it checks to see if move_ai() is already running. If so, it
247 doesn't call it.
248
249 After hitting Force Move, at the end of the game I pop open the player settings.
250 It has both opponents set as AI (note, I should probably _always_ read in values
251 from the .gamazons file instead of the widget's current values). I hit ok,
252 which saves those values to my .gamazons file, and then new game. At this
253 point, both players should be AI, but it insists on waiting for the human to
254 move the AI. Also when the game starts up in this state, it insists on waiting
255 for the human to start.
256
257 If both players are set to AI, and I have 'while(move_ai)' call in my main init
258 function, the board doesn't have a chance to get drawn until the game is over.
259 SOLUTION: Don't call 'while(move_ai)' from init_game_board(). If the user
260 really wants the AIs to play against each other right away, he'll have to select
261 New from the menu.
262
263 ugh, now when I autofinish & select New game, I can't move my piece. SOLUTION:
264 move_ai() only changed the what_next variable if an AI player actually moved.
265 Since New Game initialized what_next to WAIT_FOR_AI before calling move_ai() and
266 White was set as a human player, we were stuck in WAIT_FOR_AI mode and couldn't
267 move any pieces. To solve this, I move the code that updated what_next outside
268 of the "if AI is moving" block.
269
270 If you hit 'autofinish' after the game has ended, selecting 'new game' doesn't
271 start the game in a useable state. It's white's turn to move, it's set as
272 human, but what_next = MOVE_AI. SOLUTION: Disable Autofinish & Force move at
273 end of game.
274
275 A4-C6, A7, undo moves the white piece on top of the black piece. Solution: the
276 new gui state machine only updates the to/from values when a legal move occurs.
277
278 if you make a move, then change the theme, and press undo, the thing totally wigs
279 out. SOLUTION: Disable 'Settings' menu inbetween moving a piece and firing an
280 arrow.
281
282 move d1-d10, as it slides back, move a4-g10. it freezes momentarily, now move
283 j4 quickly to a7 and now x is dead or your window mgr freezes. SOLUTION: Don't
284 allow other game pieces to be picked up when another piece is sliding.
285
286 search time = 1, max depth=0, max width = 0, white = AI, black = AI, press ok.
287 You get a bazillion error messages and the pieces don't play. SOLUTION: set the
288 minimum max-depth value to be 1.
289
290 After setting both players to AI, completing a game, selecting white as human
291 and starting a new game, I can't pick up the white pieces. SOLUTION: new board
292 state machine fixed this.
293
294 Playing with setting both players to AI, w/ time = 1, depth=1, width=0. trying various
295 combinations of depth=0/1 and width=0/1. Sometimes I can't get the game to start w/
296 both as AI, and switching to white=human, I can't pick up the pieces. SOLUTION:
297 new board state machine fixed this.
298
299 settings->theme, press OK w/o selecting a theme. Program quits w/ error, cannot
300 open theme *.theme. SOLUTION: have load theme from file return FALSE if it
301 can't open the file, then handle the problem gracefully instead of trying to
302 process it.
303
304 Ack! isearch() returns a move struct. Not a pointer to a move struct. Note:
305 the data holding this move struct is located in isearch(), and once this function
306 returns, its value is no longer guaranteed to be valid! It just _usually_ is.
307 This is the most likely cause of the repeated FORCE MOVE button coming back with
308 wacked out moves. I'm getting moves like: 50. g-6375-g-6408, d-6318 and
309 a1-g-6377, b-6358 SOLUTION: make sure isearch returns a valid move struct
310
311 ================================================================================
312 BUGS
313 ================================================================================
314
315 Anca somehow managed to lose a queen in the middle of the game when it was moved
316 to the right edge of the screen. She was more inclined to miss her target
317 square & hit undo, but so far I haven't been able to replicate it.
318
319 When restarting a game, I should free the malloc'ed board struct.
320 destroy_board() would probably be a good place for this.
321
322 0.81 bugs:
323
324 Have theme window open, press autofinish. Select theme. It's not autofinishing
325 anymore, and the settings menu is blocked out. Also, if the theme changes while
326 a piece is in midmove, it wigs out.
327
328 Changing themes as a piece is moving makes it wig out.
329
330 If you have a settings window open, then make a partial move you can then change
331 any settings and muck up the game.
332
333 Pressing undo again as the piece is sliding back loses a queen.
334
335 dragging a queen off the board miscalculates its location: ie A4-D3 but further
336 off to the right, the queen slides back to A2, during which time you can press
337 undo and totally muck it up.
338
339 Set white=AI, black=HUMAN. New Game. White moves, change black to AI. Black
340 moves, white never moves again.
341
342 Move history is screwed up. G1-G7, D7: history shows d10-g7, d7
343
344 0.82 Todo
345
346 when a window is open, ignore all clicks on the board. This will keep people
347 from opening settings windows, then making partial moves etc...
348 - What about only being able to open a single window? Ie - if I have
349 two windows open, and I close one, the open_window count is set to false and
350 it doesn't know there are other windows open. Instead of having TRUE/FALSE,
351 values, inc/dec the counter, and when it's zero it's safe to reenable
352 buttons.
353 X Disable certain interrupts when a piece is sliding (ie theme changes, undo, etc)
354
355 X Do error checking on board location. If a piece is out of bounds, it's not a
356 valid move.
357
358 X Fix history window for human moves
359
360 X Fix state machine processing of player setting changes.