# SLU CHESS - PowerPoint PPT Presentation

PPT – SLU CHESS PowerPoint presentation | free to download - id: 4eee1-Mzg0M

The Adobe Flash plugin is needed to view this content

Get the plugin now

View by Category
Title:

## SLU CHESS

Description:

### Presented by James Cofield. Graphics A Larkian approach. Please wait while processing... Legal Move Rook. int xCoordinate = xPosition( prevSquare ) ... – PowerPoint PPT presentation

Number of Views:66
Avg rating:3.0/5.0
Slides: 14
Provided by: solse
Category:
Transcript and Presenter's Notes

Title: SLU CHESS

1
SLU CHESS
• By James Cofield
• Dustin Dotson
• Travis Larkins
• Forest Marie
• Accidental Productions 2002

2
Introduction
• Who are we?

3
Documentation
• --Presented by James Cofield

4
GraphicsA Larkian approach

5
Chess logic and math
1 2 3 4 5 6 7 8
9 10 11 12 13 14 15 16
17 18 19 20 21 22 23 24
25 26 27 28 29 30 31 32
33 34 35 36 37 38 39 40
41 42 43 44 45 46 47 48
49 50 51 52 53 54 55 56
57 58 59 60 61 62 63 64
A B C D E F G H
6
Setting up the board
• char pieceIdentifiers 66
• strcpy( pieceIdentifiers, _rnbqkbnrpppppppp
. PPPPPPPPRNBKQBNR)
• for ( int walker 1 walker lt 64 i )
• DrawPieceToBoard( walker,
pieceIdentifiers walker )

7
X-Y Position
• struct Square int squarePosition
• int xPosition ( Square square ) return ( 1
( ( square 1 ) 8 )
• Why not square 8?
• Consider the positions of 8n, where 1 lt n lt 8.
• int yPosition( Square square ) return 8
(( square 1 ) / 8 )

8
Legal MovePawns
• int moveDifference abs(xPosition(
prevSquarePosition ) ) - abs(xPosition(currSquar
ePosition))
• LegalPawnMove()
• if ( yPosition( prevSquarePosition )
yPosition( currSquarePosition ) 1 )
• if ( !moveDifference ) // if not zero
• if ( pieceIdentifiers
currSquarePosition )
• return true
• else
• if ( moveDifference 1 ) //Possible
capture!
• if ( ( PieceColor( currSquare )
Black )
• return true
• else
• if ( ( yPosition( prevSquare 2 )
( yPosition( currSquare 4 ) )
• if ( !moveDifference
pieceIdentifer currSquarePosition
• pieceIdentifier
prevSquarePosition currSquarePosition / 2
)
• return true

9
Legal MoveKnights
• int moveDifferenceX abs(( xPosition(
prevSquarePosition )

• xPosition( currSquarePosition ) )
• int moveDifferenceY abs(( yPosition(
prevSquarePosition )

• yPosition( currSquarePosition )
• if ( moveDifferenceX 2 moveDifferenceY
1 )
• if ( PieceColor( currSquarePosition )
White
• pieceIdentifier
currSquarePosition )
• return true
• else
• if ( moveDifferenceX 1
moveDifferenceY 2 )
• if( PieceColor( currSquarePosition
) White
• pieceIdentifier
currSquarePosition )
• return true
• else
• return false

10
Legal MoveBishops
• int xCoordinate xPosition( prevSquare )
• int yCoordinate yPosition( prevSquare )
• Square boardRunner
• int pieceColor PieceColor( prevSquare )
• for ( int x -1 x lt 1 x 2 )
• for ( int y -1 y lt 1 y 2 )
• for ( int z 1 z lt 7 z )
• boardRunner
MouseToSquare( xCoordinate x z, yCoordinate
y z )
• //if the next squre is
blank or the opposit color of this, test to see
if the
• //drop location equals
boardRunner
• if ( PieceColor(
boardRunner ) BLANK ( PieceColor(
boardRunner ) !
• pieceColor )
• if (
boardRunner currSquare ) //the location tested
equals the dropped location.
• return
true
• else if (
PieceColor( boardRunner ) ! )

• break

11
Legal MoveRook
• int xCoordinate xPosition( prevSquare )
• int yCoordinate yPosition( currSquare )
• Square boardRunner
• int pieceColor PieceColor( prevSquare )
• //Run up X side.
• for ( int x -1 x lt1 x 2 )
• for ( int r -1 r lt 7 r )
• boardRunner
MouseToSquare( xCoordinate x r, yCoordinate
)
• if ( PieceColor(
boardRunner ) BLANK PieceColor(
boardRunner ) ! pieceColor )
• if ( v currSquare
)
• return true
• else if (
PieceColor( boardRunner ) ! ) break
• //Run up Y side.
• for ( int y -1 y lt1 y 2 )
• for ( int r 1 r lt7 r )
• .

12
Legal MoveQueens
• bool legalQueenMove legalBishopMove(
prevSquarePosition, currSquarePosition )
• return ( legalQueenMove true ) ?
legalQueenMove legalRookMove(
prevSquarePosition,
• currSquarePosition )

13
Legal MoveKings
• int xCoordinate xPosition( currSquarePosition
)
• int yCoordinate yPosition( currSquarePosition
)
• int xDifference abs( ( xPosition(
prevSquarePosition ) xPosition(
currSquarePosition ) )
• int yDifference abs( ( yPosition(
prevSquarePosition ) yPosition(
currSquarePosition ) )
• if ( xDifference lt1 yDifference lt1
!whiteInCheck( currSquarePosition )
• return true
• if( SquarePositionLiteral(oldSquarePosition )
E1 SquarePositionLiteral( currSquarePosition )
G1 CastlingAllowed( WhiteKingSide )
!whiteInCheck( currSquarePosition ) )
• return true
• else
• if ( SquarePositionLiteral( oldSquarePosition )
E1 SquarePositionLiteral(
currSquarePosition ) C1 CastlingAllowed(
WhiteQueenSide ) !whiteInCheck(
currSquarePosition ) )
• return true