Table of Contents

Class: Board chess.py

Representation of a chessboard.

Methods   
__init__
__repr__
asArray
at
check
checkmate
clear
clone
couldMove
findAll
findAllByKind
findAllNonKings
findByKind
get
king
move
pieces
place
pretty
prettyMarkup
reset
selectAll
selectFirst
set
show
showMarkup
take
threat
wouldCheck
  __init__ 
__init__ ( self )

  __repr__ 
__repr__ ( self )

  asArray 
asArray ( self )

Return the state of the board as an array of arrays of chars.

  at 
at ( self,  loc )

Return piece at LOC or None.

  check 
check ( self,  color )

Is COLOR in check?

  checkmate 
checkmate ( self,  color )

Is COLOR checkmated?

  clear 
clear ( self )

Clear the board.

  clone 
clone ( self )

Make a clone of the entire board (including pieces).

  couldMove 
couldMove (
        self,
        end,
        color,
        )

If it were COLOR's turn, who could move to END?

  findAll 
findAll ( self,  color )

Return a list of all pieces of color COLOR.

  findAllByKind 
findAllByKind (
        self,
        kind,
        color,
        )

Return a list of all piece of type KIND and color COLOR.

  findAllNonKings 
findAllNonKings ( self,  color )

Return a list of all non-king pieces of color COLOR.

  findByKind 
findByKind (
        self,
        kind,
        color,
        )

Return first found piece of type KIND and color COLOR or raise.

Exceptions   
NoMatchesError
  get 
get ( self,  loc )

Return piece at LOC or raise.

Exceptions   
EmptySquareError
  king 
king ( self,  color )

Return COLOR's king.

  move 
move (
        self,
        start,
        end,
        )

Move a piece from START to END.

  pieces 
pieces ( self )

Get a list of all pieces on the board.

  place 
place (
        self,
        loc,
        piece,
        )

Place a previously-taken PIECE at LOC.

  pretty 
pretty ( self,  rep )

Return a "pretty" ASCII representation of the board represented by REP.

  prettyMarkup 
prettyMarkup ( self,  rep )

Return a marked-up "pretty" representation. Internal use only.

  reset 
reset ( self )

Reset the board to the base state.

  selectAll 
selectAll ( self,  func )

Return all pieces where FUNC returns true.

  selectFirst 
selectFirst ( self,  func )

Return the first piece where FUNC returns true or raise.

Exceptions   
NoMatchesError
  set 
set ( self,  rep )

Set the board to the configuration indicated by the string REP.

  show 
show ( self )

Return a "pretty" ASCII representation of the current state of the board.

  showMarkup 
showMarkup ( self )

Show a marked-up "pretty" representation. Internal use only.

  take 
take ( self,  loc )

Remove a piece at LOC (in preparation for moving it) and return it.

Exceptions   
EmptySquareError
  threat 
threat (
        self,
        loc,
        color,
        )

What pieces can currently threaten LOC if it were covered with a COLOR piece?

  wouldCheck 
wouldCheck (
        self,
        start,
        end,
        color=None,
        )

If a COLOR piece moved from START to END, would COLOR's king be in check?


Table of Contents

This document was automatically generated on Thu Jul 25 17:22:53 2002 by HappyDoc version 2.0.1