![]() ![]() ![]()
Make sure to copy all of the code after this text: I HAVING PROBLEMS WITH MY DINOSAUR CHESS SOFTWARE HOW TOIf you want to know how to move your pieces, type a2-a4 as an example. If you are having difficulties with the other code, I improved it with some minor fixes. direction)) # the condition after the and is to make sure the non-capturing movement (the only fucking one in the game) is not used in the calculation of checkmate direction) not in gameboard and Color = self. noConflict( gameboard, Color, x - 1, y + self. noConflict( gameboard, Color, x + 1, y + self. direction should be either 1 or -1, should be -1 if the pawn is traveling "backwards" #of course, the smallest piece is the hardest to code. AdNauseum( x, y, gameboard, Color, chessCardinals + chessDiagonals)ĭef _init_( self, color, name, direction): AdNauseum( x, y, gameboard, Color, chessDiagonals) AdNauseum( x, y, gameboard, Color, chessCardinals) Return ĭef availableMoves( self, x, y, gameboard, Color = None):ĭef availableMoves( self, x, y, gameboard, Color = None): """sepcifically for the rook, permutes the values needed around a position for noConflict tests""" Color != initialColor) : return TrueĬhessCardinals = ĬhessDiagonals = isInBounds( x, y) and ((( x, y) not in gameboard) or gameboard. "checks if a single position poses no conflict to the rules of chess" Xtemp, ytemp = xtemp + xint, ytemp + yintĭef noConflict( self, gameboard, initialColor, x, y): #print(str((xtemp,ytemp))+"is in bounds") If that piece is not of the same color, that square is added and """repeats the given interval until another piece is run into. Print( "ERROR: no movement for base class")ĭef AdNauseum( self, x, y, gameboard, Color, intervals): availableMoves( startpos, startpos, gameboard, Color = Color):ĭef availableMoves( self, x, y, gameboard): ischeck(mate) is run, and if there is a checkmate, the game prints a message as to who winsĭef isValid( self, startpos, endpos, Color, gameboard): if the move conflicts with another piece, that piece is removed. contains the following members and methods:Ĩx8 piece array with references to these piecesĪ parse function, which turns the input from the user into a list of two tuples denoting start and end pointsĪ checkmateExists function which checks if either players are in checkmateĪ checkExists function which checks if either players are in check (woah, I just got that nonsequitur)Ī main loop, which takes input, runs it through the parser, asks the piece if the move is valid, and moves the piece if it is. If type(arg) is not type(1) or type(arg) is not type(1): #checks if any pieces in piece list (which is an array of (piece,position) tuples) can see the king in kingpos message = "Black player is in check"ĭef canSeeKing( self, kingpos, piecelist): #ascertain where the kings are, check all pieces of opposing color against those kings, then if either get hit, check if its checkmateįor position, piece in self. message = "there is no piece in that space" availableMoves( startpos, startpos, self. message = "you aren't allowed to move that piece this turn" message = "could not find piece index probably out of range" enter moves in algebraic notation separated by space") message = "this is where prompts will go" #ive decided since the number of pieces is capped but the type of pieces is not (pawn transformations), I've already coded much of the modularity to support just using a dictionary of pieces This corresponds to the alpha-number system in traditional chess while being computationally useful. Positions are done row-column from the bottom left and are both numbers. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |