Graphical User Interface Procedures
Note: The advanced gui for gamesman is not required and is only
for those that want extra credit. All of the following procedures are for the advanced gui. For basic
gui instructions, please read the
graphics page under Assignment.
All of the following functions must be written in order to impliment all of the GUI for this
project. Note that aside from the first function, the following show potential moves,
place moves or undo moves. In general, when showing potential moves, you want to show the piece of
whoseever turn it is in all the appropriate empty spaces with the appropriate color. Then hiding
these actions takes away the added potential pieces leaving all the real pieces that actually have
been placed. You may assume that the hide functions will only be called after their according shows.
The handle-* functions actually place or undo a piece that is real.
Unlike the previous functions, these are not potential pieces. With the
gui-handle-undo function, you can also assume that the piece has already been placed
using gui-handle-move .
Also, in addition to the functions that are listed below, you must make the call somewhere within
your module to (gui-return-from-human-move move) where move is the move that
the player has entered. The procedure that is likely to call this is whatever handles your mouse
input. Note that you CAN pass this procedure a bad move. It will do absolutely nothing if the move is
not valid. So, there is no need to error check with the move that is sent to this procedure. Notice
in tic-tac-toe how the procedures that are bound to the click of all x's, o's , and the background
picture call the procedure make-board-move which takes the move and passes it on to
gui-return-from-human-move .
The Functions
•(gui-init-board initial-position)
gui-init-board is the first essential function that must be written. Here, you want
to do anything that you need to do in order to prepare your board. Note that this sets up the
inital-board configuration, meaning any grid or similar background
type of item in addition to setting up pieces appropriate to the
initial-position. Anything that is not activated by a move or by
changing the settings for viewing value moves, safe moves ... is
done here. This function takes initial position as
argument.
•(gui-show-all-moves position movelist)
gui-show-all-moves is a function that is used to show all types of moves regardless
of how good they are (win, lose,tie, draw). This function takes in the position, and a list of all of
the possible moves from the position. (Gamesman calls it with this, so assume that much). You want to
show all the possible moves in grey, or a similar color that resembles a general move. Note that you
might want to have a legend of some sort if you deviate from our convention, especially if whatever you
have done is not obvious. So for example, in tic tac toe, this will put grey pieces of who ever's turn
it is in every non-occupied spot since at any given time, a person can place a piece in any empty space.
•(gui-hide-all-moves position movelist)
gui-hide-all-moves should change the board back to the previous state that it was in
before to the call from gui-show-all-moves . This takes in as arguments the position and
a list of all possible moves. So for example, in tic tac toe, when gui-show-all-moves
is called and it is X's turn, every empty space has a gray X put in it, so when
gui-hide-all-moves is called, all the gray x's are removed, leaving the original, normal
colored pieces (which include both x's and o's).
•(gui-show-value-moves position win-moves lose-moves tie-moves draw-moves)
gui-show-value-moves is a function that is meant to show all of the moves, and color
them according to their value (win, lose, tie, or draw). So, in tic tac toe, all of the moves are
shown with yellow pieces being draws, and red pieces being losing positions. Notice that there are no
draw-moves, because nothing is a draw sice there is no loopyness, and also notice that there is no
winning move (green) unless one player screws up. The input to this function is a position, a list of
all winning moves, a list of all losing moves, a list of all the tie moves, and a list of all the
draw moves, in that order. Again as above, try to use our color conventions.
•(gui-hide-value-moves position win-moves lose-moves tie-moves draw-moves)
gui-hide-value-moves should take away all the pieces that were placed in a call to
gui-show-value-moves leaving all the original pieces.
•(gui-show-safe-moves position movelist value)
gui-show-safe-moves is a function that is meant to show all of the safe moves, being
the highest type value move. If there are wins possible, this shows them (in green). If there are
ties possible, show them (in yellow). If there are draws possible, then show them (in yellow).
Finally if the only thing possible is a loss, then show all possible moves as losses (red). This is
easy for you though because we give you the value of what it is. The function takes in the position,
the list of moves (all of which are safe) and a value which is a letter (w,l,t,d). You have to show
all the moves in the list of safe moves in the appropriate color dictated by the value.
•(gui-hide-safe-moves position movelist value)
gui-hide-safe-moves should take away all the pieces that were placed in a call to
gui-show-show-moves leaving all the original pieces.
•(gui-handle-undo current-position move-to-undo position-after-undo)
gui-handle-undo is used to undo moves. It takes in the current position, the move to
undo, and the position after the undo. You must undo whatever graphical move you just did. Unlike the
previous functions where you take away items representing potential moves colored by value or gray,
here, you want to undo your "normal" piece given by the previous move that did the deed of placing
it.
•(gui-handle-move old-position move new-position)
gui-handle-move is a function that is used to do a move and place a piece. This takes
in the old-position, the move and the new position after the move is done. You must place a "normal"
piece according to the move. Note that this might be a good place for animation (as is
gui-handle-undo if you want).
|