DM3BA-Play Gameby*********************** *** DM3BA-Play Game *** *********************** Subordinate design modules: ======= DM4BAA-Logic FUNCTION LegalMove% (Move AS STRING) - Given a move such as e2-e4 this returns as follows: 0=Not possible 1=Illegal 2=Allowed FUNCTION ExistsAValidMove% (c$) - Given either "White" or "Black" this returns as follows: -1 = There exists a legal move for that color 0 = There is no legal move FUNCTION IsInCheck$ (c$) - Given either "White" or "Black" this returns as follows: --- = Not in check N-- = In check by a knight" -L- = In check on the long diagonal" -S- = In check on the short diagonal" --R = In check on the rank" --F = In check on the file" -LF = (example multiple checks)" ======= DM4BAB-Make Move FUNCTION MakeMove%(c$) - Given either "White" or "Black" this returns as follows: 1 = A move was made 2 = Will move later (wants to exit program) 3 = Game Over Determine if player has a legal move. If not, determine whether Stalemate or Checkmate Change any en-passent moves for the player to normal Show board and prompt for move Ensure move is valid via LegalMove function. If not, prompt again. Give proper calls to WindowSub: Illegal move Legal Move Not possible Pawn gone Piece gone White (or Black) cannot move - stalemate! White (or Black) is in check by a Knight White (or Black) is in check on the long diagonal White (or Black) is in check on the short diagonal White (or Black) is in check on the rank White (or Black) is in check on the file White (or Black) loses - checkmate! White (or Black) promotes White (or Black) to move with possible pawn capture(s) White (or Black) to move Fix Board to show move taken. ======= DM4BAC-InputOutput SUB SecureEncryptAndWrite (Game$, Key#, pb$, Pw$, Who%) SUB SecureReadAndDecrypt (Game$, Key#, pb$, Pw$, Who%) - Given Game$ such as "Don", read or write "Don.ksg" - Encrypt or Decrypt using FUNCTIONs GetKey, ksgEncrypt, and ksgDecrypt - Save and Restore shared arrays Board, WBoard and BBoard. - Save and Restore Pb$ and Pw$ (Password checks for players) - Save and Restore Who% (Whose turn) ======= DM4BAD-Main DECLARE SUB RefereeSpeaks (Msg$) - To be used to capture and replay referee calls. MAIN - Control the program according to Whose Turn. 0=Need PasswordB 1=NeedPassW 2=White's move 3=Black's move 4=Black needs to acknowledge game over 5=White needs to acknowledge game over 6=Game Over On first call (new game) Get Black's password, initialize Board and set Who%=1 On subsequent calls (old game) Who%=1: Get White's password, set Who%=2 Who%=2: Verify White's password, let White move Continue according to MakeMove result 1 = A move was made, set Who%=3 2 = Will move later (wants to exit program), leave with Who%=2 3 = Game Over, Set Who%=4 Who%=3: Verify Black's password, let Black move Continue according to MakeMove result 1 = A move was made, set Who%=2 2 = Will move later (wants to exit program), leave with Who%=3 3 = Game Over, Set Who%=5 Who%=4: Verify Black's password, set Who%=6 Who%=5: Verify White's password, set Who%=6 Who%=6: Display Whole Board Normal play: Player's move. Continue according to MakeMove result 1 = A move was made, it is the other player's move If the other player is remote, hit return on password prompt to exit,transfer xxx.ksg 2 = Will move later (wants to exit program) Start program again to continue 3 = Game Over Transfer xxx.ksg to other player to acknowledge When other player acknowledges, show board ======= DM4BAE-Passwords Note: c$="White" or "Black" FUNCTION Authorized% (c$, Pw#) Given Pw$=password verifier, prompt user for password and compute whether it is valid. Return 0 for no, -1 for yes. FUNCTION GetInitialPassword# (c$) Prompt user for password. Compute and return a password verifier.
from IP address 68.98.164.60 |