chess.py - Author Update Description Add one from graphics...

This preview shows page 1 - 2 out of 2 pages.

###### Author: Update.### Description: Add one.###from graphics import graphicsW_KNIGHT = 'WKn'W_KING = 'WKi'B_KNIGHT = 'BKn'B_KING = 'BKi'EMPTY = ' 'WHITE = 'White'BLACK = 'Black'LEFT = 'l'RIGHT = 'r'def is_valid_move(board, position, player):''' Implement. '''board = [W_KING,W_KNIGHT,W_KNIGHT,EMPTY,EMPTY,EMPTY,B_KNIGHT,B_KNIGHT,B_KING]for position in len(board):if position >= 0 or position <= 8:return Trueelse:return Falsedef move_knight(board, position, direction):''' Implement. '''def move_king(board, position, direction):''' Implement. '''def print_board(board):''' Implement. '''print('+-----------------------------------------------------+')print('| '+W_KING+' | '+W_KNIGHT+' | '+ W_KNIGHT+' | '+EMPTY+'| '+EMPTY+'|'+EMPTY+'| '+B_KNIGHT+' | '+B_KNIGHT+' | '+B_KING+' |')print('+-----------------------------------------------------+')def draw_board(board, gui):''' Implement. '''def is_game_over(board):''' Implement. '''def move(board, position, direction):''' Implement. '''def main():# Create the canvasgui = graphics(700, 200, '1 Dimensional Chess')# This is the starting board.

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture