43
C SC 483 Chess and AI: Computation and Cognition Lecture 3 September 10th

C SC 483 Chess and AI: Computation and Cognitionelmo.sbs.arizona.edu/sandiway/CSC483/lecture3.pdf · A4 B4 C4 D4 E4 F4 G4 H4 D8 D7 D6 D5 D4 D3 D2 D1 A3 B3 C3 D3 E3 F3 G3 H3 C8 C7

  • Upload
    others

  • View
    5

  • Download
    0

Embed Size (px)

Citation preview

Page 1: C SC 483 Chess and AI: Computation and Cognitionelmo.sbs.arizona.edu/sandiway/CSC483/lecture3.pdf · A4 B4 C4 D4 E4 F4 G4 H4 D8 D7 D6 D5 D4 D3 D2 D1 A3 B3 C3 D3 E3 F3 G3 H3 C8 C7

C SC 483Chess and AI: Computation

and CognitionLecture 3

September 10th

Page 2: C SC 483 Chess and AI: Computation and Cognitionelmo.sbs.arizona.edu/sandiway/CSC483/lecture3.pdf · A4 B4 C4 D4 E4 F4 G4 H4 D8 D7 D6 D5 D4 D3 D2 D1 A3 B3 C3 D3 E3 F3 G3 H3 C8 C7

Programming Project

• A series of tasks

• There are lots of resources and opensource code available for chess

• Please don’t simply copy and paste• Learn by writing your own code!

Page 3: C SC 483 Chess and AI: Computation and Cognitionelmo.sbs.arizona.edu/sandiway/CSC483/lecture3.pdf · A4 B4 C4 D4 E4 F4 G4 H4 D8 D7 D6 D5 D4 D3 D2 D1 A3 B3 C3 D3 E3 F3 G3 H3 C8 C7

Task 1

• Set up graphical representation of chessboard– allow you to set up chess positions– allow you to move pieces

– recommend using the Tk toolkitfor this project

– many variants:(see wiki Tk page)

Page 4: C SC 483 Chess and AI: Computation and Cognitionelmo.sbs.arizona.edu/sandiway/CSC483/lecture3.pdf · A4 B4 C4 D4 E4 F4 G4 H4 D8 D7 D6 D5 D4 D3 D2 D1 A3 B3 C3 D3 E3 F3 G3 H3 C8 C7

Chess Pieces• for the class, let’s all use these pieces• taken from Apple’s Symbol font• chess pieces are unicode characters 2654 to 265F

Page 5: C SC 483 Chess and AI: Computation and Cognitionelmo.sbs.arizona.edu/sandiway/CSC483/lecture3.pdf · A4 B4 C4 D4 E4 F4 G4 H4 D8 D7 D6 D5 D4 D3 D2 D1 A3 B3 C3 D3 E3 F3 G3 H3 C8 C7

Chess Pieces

• download fromcourse webpage– bmp.zip

– 64 x 64 pixelbitmaps

Page 6: C SC 483 Chess and AI: Computation and Cognitionelmo.sbs.arizona.edu/sandiway/CSC483/lecture3.pdf · A4 B4 C4 D4 E4 F4 G4 H4 D8 D7 D6 D5 D4 D3 D2 D1 A3 B3 C3 D3 E3 F3 G3 H3 C8 C7

Chessboard

• Example:– done in tcl/tk– about one

page of code

Page 7: C SC 483 Chess and AI: Computation and Cognitionelmo.sbs.arizona.edu/sandiway/CSC483/lecture3.pdf · A4 B4 C4 D4 E4 F4 G4 H4 D8 D7 D6 D5 D4 D3 D2 D1 A3 B3 C3 D3 E3 F3 G3 H3 C8 C7

Task 2

• Compute possible legal moves andattacks

Page 8: C SC 483 Chess and AI: Computation and Cognitionelmo.sbs.arizona.edu/sandiway/CSC483/lecture3.pdf · A4 B4 C4 D4 E4 F4 G4 H4 D8 D7 D6 D5 D4 D3 D2 D1 A3 B3 C3 D3 E3 F3 G3 H3 C8 C7

Underlying Representation

• Behind the scenes:– use a bitboard to represent where pieces are– reasons:

• fast• bit operations• easy to answer many questions fairly directly

Page 9: C SC 483 Chess and AI: Computation and Cognitionelmo.sbs.arizona.edu/sandiway/CSC483/lecture3.pdf · A4 B4 C4 D4 E4 F4 G4 H4 D8 D7 D6 D5 D4 D3 D2 D1 A3 B3 C3 D3 E3 F3 G3 H3 C8 C7

Bitboard Representation• 64 bits

– integers: typically 32 bits (4 bytes)– use 64 bit integers: C’s (unsigned) long long, uint64_t– Example:

• initial position: black pawns• 0x000000000000FF00 (hex)

00000000

00000000

00000000

00000000

00000000

00000000

11111111

00000000

one hex digit

use any reasonable mappingyou like: of course, as long asyou are consistent

Page 10: C SC 483 Chess and AI: Computation and Cognitionelmo.sbs.arizona.edu/sandiway/CSC483/lecture3.pdf · A4 B4 C4 D4 E4 F4 G4 H4 D8 D7 D6 D5 D4 D3 D2 D1 A3 B3 C3 D3 E3 F3 G3 H3 C8 C7

Bitboard Representationyou could use columnmajor or row major order,count up from the bottomvs. from the top (or left vs.right)

• my chosenrepresentation:lsb = least significant bitmsb = most significant bit

• bitboard =

lsbmsb byte 1

byte 8

byte1byte2byte3byte4byte5byte6byte7byte8

Page 11: C SC 483 Chess and AI: Computation and Cognitionelmo.sbs.arizona.edu/sandiway/CSC483/lecture3.pdf · A4 B4 C4 D4 E4 F4 G4 H4 D8 D7 D6 D5 D4 D3 D2 D1 A3 B3 C3 D3 E3 F3 G3 H3 C8 C7

Bitboard Representation• Encoding a 1 step move (by black pawns):

– 0x000000000824C300 –> 0x0000000824C30000– left shift by 8 positions (=1 row)– i.e. 0x000000000824C300 << 8

00000000

00000000

00000000

00000000

00010000

00100100

11000011

00000000

00000000

00000000

00000000

00010000

00100100

11000011

00000000

00000000

Page 12: C SC 483 Chess and AI: Computation and Cognitionelmo.sbs.arizona.edu/sandiway/CSC483/lecture3.pdf · A4 B4 C4 D4 E4 F4 G4 H4 D8 D7 D6 D5 D4 D3 D2 D1 A3 B3 C3 D3 E3 F3 G3 H3 C8 C7

Bitboard Representation

• Integer representation– signed (2’s complement)– 32 bit version

-1 = 0xFFFFFFFF-2147483648 = 0x800000002147483647 = 0x7FFFFFFF1 = 0x000000010 = 0x00000000

• this usually means weneed to be carefulwith right shifts– because of sign bit

preservation– example:

• 0x80000000 >> 1• =• 0xC0000000

Page 13: C SC 483 Chess and AI: Computation and Cognitionelmo.sbs.arizona.edu/sandiway/CSC483/lecture3.pdf · A4 B4 C4 D4 E4 F4 G4 H4 D8 D7 D6 D5 D4 D3 D2 D1 A3 B3 C3 D3 E3 F3 G3 H3 C8 C7

Bitboard Representation

• How many bitboards?– one for each type of

piece K, Q, R, B, N, P– for each side– = 12– think of them as layers or

overlays in Photoshop– (I’m going to use

lowercase for white anduppercase for black inthis presentation)

• Initially:– k 0x0800000000000000– K 0x0000000000000008– q 0x1000000000000000– Q 0x0000000000000010– r 0x8100000000000000– R 0x0000000000000081– b 0x2400000000000000– B 0x0000000000000024– n 0x4200000000000000– N 0x0000000000000042– p 0x00FF000000000000– P 0x000000000000FF00

Page 14: C SC 483 Chess and AI: Computation and Cognitionelmo.sbs.arizona.edu/sandiway/CSC483/lecture3.pdf · A4 B4 C4 D4 E4 F4 G4 H4 D8 D7 D6 D5 D4 D3 D2 D1 A3 B3 C3 D3 E3 F3 G3 H3 C8 C7

Bitboard Representation• http://www.onjava.com/pub/a/onjava/2005/02/02/bitsets.html?page=2

anotherview

Page 15: C SC 483 Chess and AI: Computation and Cognitionelmo.sbs.arizona.edu/sandiway/CSC483/lecture3.pdf · A4 B4 C4 D4 E4 F4 G4 H4 D8 D7 D6 D5 D4 D3 D2 D1 A3 B3 C3 D3 E3 F3 G3 H3 C8 C7

Bitboard Representation• white = k | q | r | b | n | p (always)• white = 0xFFFF000000000000

(initially)

• black = K | Q | R | B | N | P (always)• black = 0x000000000000FFFF

(initially)

• empty = ~ ( white | black ) (always)• empty = ~ 0xFFFF00000000FFFF

(initially)• empty = 0x0000FFFFFFFF0000

• Initially:– k 0x0800000000000000– q 0x1000000000000000– r 0x8100000000000000– b 0x2400000000000000– n 0x4200000000000000– p 0x00FF000000000000– K 0x0000000000000008– Q 0x0000000000000010– R 0x0000000000000081– B 0x0000000000000024– N 0x0000000000000042– P 0x000000000000FF00

Page 16: C SC 483 Chess and AI: Computation and Cognitionelmo.sbs.arizona.edu/sandiway/CSC483/lecture3.pdf · A4 B4 C4 D4 E4 F4 G4 H4 D8 D7 D6 D5 D4 D3 D2 D1 A3 B3 C3 D3 E3 F3 G3 H3 C8 C7

Bitboard Representation

• (Legal) pawn moves– forward one rank (if not

blocked)– forward two ranks if not

moved (and not blocked)– capture diagonally– en passant– need to check also if king

is under attack after themove

• Bitboardimplementation:– forward one rank (if not

blocked)we can operate on all thepawns at a time(bitparallel)P << 8

– need to mask out occupiedsquaresP << 8 & empty

similar considerations for p

Page 17: C SC 483 Chess and AI: Computation and Cognitionelmo.sbs.arizona.edu/sandiway/CSC483/lecture3.pdf · A4 B4 C4 D4 E4 F4 G4 H4 D8 D7 D6 D5 D4 D3 D2 D1 A3 B3 C3 D3 E3 F3 G3 H3 C8 C7

Bitboard Representation• Bitboard implementation:

– forward two ranks if notmoved (and not blocked)

– define• rank7 = 0x000000000000FF00

– then((P & rank7) << 8 & empty) <<8 & empty

– similar considerations for p– rank2 = 0x00FF000000000000

• Bitboard implementation:– capture diagonally– define

• filea = 0x8080808080808080• fileh = 0x0101010101010101

– for black– attacks down and to the right

(P & ~fileh) << 7– Attacks down and to the left

(P & ~filea) << 9

– similar considerations for p

Page 18: C SC 483 Chess and AI: Computation and Cognitionelmo.sbs.arizona.edu/sandiway/CSC483/lecture3.pdf · A4 B4 C4 D4 E4 F4 G4 H4 D8 D7 D6 D5 D4 D3 D2 D1 A3 B3 C3 D3 E3 F3 G3 H3 C8 C7

Bitboard Representation• Bitboard implementation:

– capture diagonally– define

• filea =0x8080808080808080

• fileh =0x0101010101010101

– for black– attacks down and to the

right(P & ~fileh) << 7

• Why ~fileh?

Page 19: C SC 483 Chess and AI: Computation and Cognitionelmo.sbs.arizona.edu/sandiway/CSC483/lecture3.pdf · A4 B4 C4 D4 E4 F4 G4 H4 D8 D7 D6 D5 D4 D3 D2 D1 A3 B3 C3 D3 E3 F3 G3 H3 C8 C7

Bitboard Representation• Bitboard implementation:

– capture diagonally– define

• filea =0x8080808080808080

• fileh =0x0101010101010101

– for black– attacks down and to the

right(P & ~fileh) << 7

• Why ~fileh?

fileh

Page 20: C SC 483 Chess and AI: Computation and Cognitionelmo.sbs.arizona.edu/sandiway/CSC483/lecture3.pdf · A4 B4 C4 D4 E4 F4 G4 H4 D8 D7 D6 D5 D4 D3 D2 D1 A3 B3 C3 D3 E3 F3 G3 H3 C8 C7

Bitboard Representation• Bitboard implementation:

– en passant– only get one chance, so need to

know previous move– suppose black moved pawn two

squares last move, let P* beposition

– then, for whitep1 = p & rank5 ≠0P1 = P* << 1 & p1P2 = P* >> 1 & p1P1 or P2 non-zeroP* >> 8 & empty ≠0

– similar considerations for black

Page 21: C SC 483 Chess and AI: Computation and Cognitionelmo.sbs.arizona.edu/sandiway/CSC483/lecture3.pdf · A4 B4 C4 D4 E4 F4 G4 H4 D8 D7 D6 D5 D4 D3 D2 D1 A3 B3 C3 D3 E3 F3 G3 H3 C8 C7

Bitboard Representation• King moves

– one step in any direction toan empty square oropponent’s square that isnot attacked(excluding castling)

– messy to compute bitoperations at run time andmask off relevant edges

– could pre-compute possiblenext moves

– and use an associativearray (hash table) for lookup

• bit operations:

>>8

<<8 <<7<<9

>>9>>7

>>1<<1

k_moves(k) & ( black | empty )

Page 22: C SC 483 Chess and AI: Computation and Cognitionelmo.sbs.arizona.edu/sandiway/CSC483/lecture3.pdf · A4 B4 C4 D4 E4 F4 G4 H4 D8 D7 D6 D5 D4 D3 D2 D1 A3 B3 C3 D3 E3 F3 G3 H3 C8 C7

Bitboard Representation

• King moves– one step in any direction

to an empty square oropponent’s square that isnot attacked(excluding castling)

• Logic:– let bb be the bitboard

associated with a king(black or white)

– squares are:(bb & ~ rank8) >> 8 | (bb &~ rank1) << 8 | (bb & ~ fileh)>> 1 | (bb & ~ filea) << 1 |(bb & ~ ( rank8 | filea)) >> 7| (bb & ~ ( rank8 | fileh)) >>9 | (bb & ~ (rank1 | fileh ))<< 7 | (bb & ~ (rank1 | filea)) << 9

>>8

<<8 <<7<<9

>>9>>7

>>1<<1

Page 23: C SC 483 Chess and AI: Computation and Cognitionelmo.sbs.arizona.edu/sandiway/CSC483/lecture3.pdf · A4 B4 C4 D4 E4 F4 G4 H4 D8 D7 D6 D5 D4 D3 D2 D1 A3 B3 C3 D3 E3 F3 G3 H3 C8 C7

Bitboard Representation• Logic:

– let bb be the bitboardassociated with a king (blackor white)

– squares are:(bb & ~ rank8) >> 8 | (bb &~ rank1) << 8 | (bb & ~ fileh)>> 1 | (bb & ~ filea) << 1 |(bb & ~ ( rank8 | filea)) >> 7 |(bb & ~ ( rank8 | fileh)) >> 9 |(bb & ~ (rank1 | fileh )) << 7 |(bb & ~ (rank1 | filea )) << 9

• sign extension error:

0x8000000000000000

Page 24: C SC 483 Chess and AI: Computation and Cognitionelmo.sbs.arizona.edu/sandiway/CSC483/lecture3.pdf · A4 B4 C4 D4 E4 F4 G4 H4 D8 D7 D6 D5 D4 D3 D2 D1 A3 B3 C3 D3 E3 F3 G3 H3 C8 C7

Bitboard Representation

• Knight moves– L-shaped pattern– can hop over pieces

• bit operations:

<<17 <<15

<<10 <<6

>>6 >>10

>>15 >>17

let bb be the bitboard associated with knights(bb & ~ (rank1 | filegh)) << 6 | (bb & ~ (rank8 | filegh)) >> 10 | (bb & ~ (rank1 | fileab)) << 10 | (bb & ~ (rank8 | fileab)) >> 6 | (bb & ~ (rank12 | fileh)) << 15 | (bb & ~ (rank12 | filea)) << 17 | (bb & ~ (rank78 | fileh)) >> 17 | (bb & ~ (rank78 | filea)) >> 15 where, e.g. filegh = fileg | fileh

Page 25: C SC 483 Chess and AI: Computation and Cognitionelmo.sbs.arizona.edu/sandiway/CSC483/lecture3.pdf · A4 B4 C4 D4 E4 F4 G4 H4 D8 D7 D6 D5 D4 D3 D2 D1 A3 B3 C3 D3 E3 F3 G3 H3 C8 C7

Bitboard Representation

• Sliding pieces• e.g. Rook

– may move along fileor rank

– extent: as farunoccupied

– capture: opposingpiece on first non-empty square on fileor rank

• Base Case– along a rank– per rook position– per bit pattern of

occupation– pre-compute

possible squaresrook could move to

Page 26: C SC 483 Chess and AI: Computation and Cognitionelmo.sbs.arizona.edu/sandiway/CSC483/lecture3.pdf · A4 B4 C4 D4 E4 F4 G4 H4 D8 D7 D6 D5 D4 D3 D2 D1 A3 B3 C3 D3 E3 F3 G3 H3 C8 C7

Bitboard Representation

• Base Case– along a rank– per rook position– per bit pattern of

occupation– pre-compute

possible squaresrook could move to

• Example:

occupation on rank8:white & black & rank8 = 1100101028 = 256 possible bit patterns

possible attack squares 01110110can mask out white (later) to eliminateattacking own piece, as in:

Page 27: C SC 483 Chess and AI: Computation and Cognitionelmo.sbs.arizona.edu/sandiway/CSC483/lecture3.pdf · A4 B4 C4 D4 E4 F4 G4 H4 D8 D7 D6 D5 D4 D3 D2 D1 A3 B3 C3 D3 E3 F3 G3 H3 C8 C7

Bitboard Representation• Rank pattern and piece lookup

(11110010,32) -> 01010000(10011110,16) -> 11101000(11000001,1) -> 01111110(11001011,1) -> 00000010(11001011,2) -> 00001101(00111000,32) -> 11010000(00110000,16) -> 00101111(01101100,64) -> 10100000(11110101,1) -> 00000110(11001011,8) -> 01110110(11110101,4) -> 00011011(11111010,64) -> 10100000(11111001,64) -> 10100000(01000000,64) -> 10111111(00100100,4) -> 00111011(11101010,32) -> 01011000(10010111,16) -> 11101100

(11100100,128) -> 01000000(01111011,1) -> 00000010(01111011,2) -> 00001101(00110000,32) -> 11010000(01001110,2) -> 00000101(01001110,4) -> 00001010(01100101,64) -> 10100000(10111100,128) -> 01100000(10100101,1) -> 00000110(01111011,8) -> 00010110(01001110,8) -> 01110100(10100101,4) -> 00111011(10011110,128) -> 01110000(11110010,64) -> 10100000(11011001,1) -> 00001110(10000000,128) -> 01111111(11100010,32) -> 01011110(11011010,16) -> 01101000

Page 28: C SC 483 Chess and AI: Computation and Cognitionelmo.sbs.arizona.edu/sandiway/CSC483/lecture3.pdf · A4 B4 C4 D4 E4 F4 G4 H4 D8 D7 D6 D5 D4 D3 D2 D1 A3 B3 C3 D3 E3 F3 G3 H3 C8 C7

Bitboard Representation• Example:

– on rank 7– white rook: 0x10 (decimal 16)– occupied: 11010001 (decimal

209)– look up through the pair rook

0x10 and pattern 209the pre-computed attacksquares: 01101111 (decimal 111or 0x6F)

– bitboard:– 0x0000000000006F00

= 0x6F << 8

• board:

Page 29: C SC 483 Chess and AI: Computation and Cognitionelmo.sbs.arizona.edu/sandiway/CSC483/lecture3.pdf · A4 B4 C4 D4 E4 F4 G4 H4 D8 D7 D6 D5 D4 D3 D2 D1 A3 B3 C3 D3 E3 F3 G3 H3 C8 C7

Bitboard Representation• Example:

– on rank 7– white rook: 0x10 (decimal 16)– occupied: 11010001

(decimal 209)– look up through the pair rook

0x10 and pattern 209the pre-computed attacksquares: 01101111 (decimal111 or 0x6F)

– bitboard:– 0x0000000000006E00

= (0x6F << 8) & ~ whitei.e mask off white pieces

• board:

Page 30: C SC 483 Chess and AI: Computation and Cognitionelmo.sbs.arizona.edu/sandiway/CSC483/lecture3.pdf · A4 B4 C4 D4 E4 F4 G4 H4 D8 D7 D6 D5 D4 D3 D2 D1 A3 B3 C3 D3 E3 F3 G3 H3 C8 C7

Bitboard Representation• Note: logic given so far

doesn’t handle two rooks onthe same rank

• Example– on rank 7– white rooks: 0x11 (decimal

17)– occupied: 11010001

(decimal 209)– lookup must be made for both

pairs– rook 0x10 and pattern 209– rook 0x01 and pattern 209– disjunctively, and then mask

off white pieces

• board:

Page 31: C SC 483 Chess and AI: Computation and Cognitionelmo.sbs.arizona.edu/sandiway/CSC483/lecture3.pdf · A4 B4 C4 D4 E4 F4 G4 H4 D8 D7 D6 D5 D4 D3 D2 D1 A3 B3 C3 D3 E3 F3 G3 H3 C8 C7

Bitboard Representation

• Similarly, lookup mustbe done disjunctively forrooks on different ranks– rook 0x10 and pattern

209– rook 0x08 and pattern 8

• board:

Page 32: C SC 483 Chess and AI: Computation and Cognitionelmo.sbs.arizona.edu/sandiway/CSC483/lecture3.pdf · A4 B4 C4 D4 E4 F4 G4 H4 D8 D7 D6 D5 D4 D3 D2 D1 A3 B3 C3 D3 E3 F3 G3 H3 C8 C7

Bitboard Representation

• Sliding pieces• e.g. Rook

– may move along fileor rank

– extent: as farunoccupied

– capture: opposingpiece on first non-empty square on fileor rank

• Base Case– along a rank

• Non-Base Case– along a file– problem: bits are not

contiguous anymore– solution: add a 90

degree rotated boardrepresentation aswell

Page 33: C SC 483 Chess and AI: Computation and Cognitionelmo.sbs.arizona.edu/sandiway/CSC483/lecture3.pdf · A4 B4 C4 D4 E4 F4 G4 H4 D8 D7 D6 D5 D4 D3 D2 D1 A3 B3 C3 D3 E3 F3 G3 H3 C8 C7

Bitboard Representation• rank order• (current representation)

• file order• (can convert: but best way is to

maintain both representations)

lsbmsb byte 1

byte 8

byte 1

Page 34: C SC 483 Chess and AI: Computation and Cognitionelmo.sbs.arizona.edu/sandiway/CSC483/lecture3.pdf · A4 B4 C4 D4 E4 F4 G4 H4 D8 D7 D6 D5 D4 D3 D2 D1 A3 B3 C3 D3 E3 F3 G3 H3 C8 C7

Bitboard Representation• Idea:

– now bits along files can be reduced to the rank lookupcase

– http://www.cis.uab.edu/hyatt/bitmaps.html

A8 B8 C8 D8 E8 F8 G8 H8 H8 H7 H6 H5 H4 H3 H2 H1A7 B7 C7 D7 E7 F7 G7 H7 G8 G7 G6 G5 G4 G3 G2 G1A6 B6 C6 D6 E6 F6 G6 H6 F8 F7 F6 F5 F4 F3 F2 F1A5 B5 C5 D5 E5 F5 G5 H5 E8 E7 E6 E5 E4 E3 E2 E1A4 B4 C4 D4 E4 F4 G4 H4 D8 D7 D6 D5 D4 D3 D2 D1A3 B3 C3 D3 E3 F3 G3 H3 C8 C7 C6 C5 C4 C3 C2 C1A2 B2 C2 D2 E2 F2 G2 H2 B8 B7 B6 B5 B4 B3 B2 B1A1 B1 C1 D1 E1 F1 G1 H1 A8 A7 A6 A5 A4 A3 A2 A1

Page 35: C SC 483 Chess and AI: Computation and Cognitionelmo.sbs.arizona.edu/sandiway/CSC483/lecture3.pdf · A4 B4 C4 D4 E4 F4 G4 H4 D8 D7 D6 D5 D4 D3 D2 D1 A3 B3 C3 D3 E3 F3 G3 H3 C8 C7

Bitboard Representation

• to be continued next time...

Page 36: C SC 483 Chess and AI: Computation and Cognitionelmo.sbs.arizona.edu/sandiway/CSC483/lecture3.pdf · A4 B4 C4 D4 E4 F4 G4 H4 D8 D7 D6 D5 D4 D3 D2 D1 A3 B3 C3 D3 E3 F3 G3 H3 C8 C7

Summary

• Task 1– construct

layout/setupgraphical display

• Task 2– compute– attacks/moves– captures– for all pieces

Show me your code and working program: in class in two weeks

Page 37: C SC 483 Chess and AI: Computation and Cognitionelmo.sbs.arizona.edu/sandiway/CSC483/lecture3.pdf · A4 B4 C4 D4 E4 F4 G4 H4 D8 D7 D6 D5 D4 D3 D2 D1 A3 B3 C3 D3 E3 F3 G3 H3 C8 C7

CHESS HOMEWORKLECTURE #3

Page 38: C SC 483 Chess and AI: Computation and Cognitionelmo.sbs.arizona.edu/sandiway/CSC483/lecture3.pdf · A4 B4 C4 D4 E4 F4 G4 H4 D8 D7 D6 D5 D4 D3 D2 D1 A3 B3 C3 D3 E3 F3 G3 H3 C8 C7

PUZZLE #1Write down 3 possible ways white can attack the F7 pawn from this

position. (2 Pts)Write down good moves white can make in this position to fight for the

Central Squares (e4,d4,e5,d5). (3 Pts).

Page 39: C SC 483 Chess and AI: Computation and Cognitionelmo.sbs.arizona.edu/sandiway/CSC483/lecture3.pdf · A4 B4 C4 D4 E4 F4 G4 H4 D8 D7 D6 D5 D4 D3 D2 D1 A3 B3 C3 D3 E3 F3 G3 H3 C8 C7

PUZZLE #21. How many legal captures does White have in this position and what are they?

(5 Pts) 2. How many legal captures does Black have in this position and what are they?

(5 Pts)

Page 40: C SC 483 Chess and AI: Computation and Cognitionelmo.sbs.arizona.edu/sandiway/CSC483/lecture3.pdf · A4 B4 C4 D4 E4 F4 G4 H4 D8 D7 D6 D5 D4 D3 D2 D1 A3 B3 C3 D3 E3 F3 G3 H3 C8 C7

RESEARCH PAPER(15 Pts)

• 1.Take 1 of the words in the“TERMINOLOGY” section under the“REQUIRED READING”.

• 2. It should be a topic (word) that you findinteresting for your own chess development.

• 3. Write a 1-2 page research paper on thatsubject, using actual examples from articles,games, chessbase, on-line sites or any othersources.

All the sources must be cited.

Page 41: C SC 483 Chess and AI: Computation and Cognitionelmo.sbs.arizona.edu/sandiway/CSC483/lecture3.pdf · A4 B4 C4 D4 E4 F4 G4 H4 D8 D7 D6 D5 D4 D3 D2 D1 A3 B3 C3 D3 E3 F3 G3 H3 C8 C7

BONUS (5Pts) http://en.wikipedia.org/wiki/World_Chess_Championship

• Choose your favorite World ChessChampion ( under the section ofUndisputed World Champions1886–1993 on that website )

• Write a short summary about his chessplaying style, strengths and contributionto the chess world.

• Must be typed.• Examples not necessary but welcome.

Page 42: C SC 483 Chess and AI: Computation and Cognitionelmo.sbs.arizona.edu/sandiway/CSC483/lecture3.pdf · A4 B4 C4 D4 E4 F4 G4 H4 D8 D7 D6 D5 D4 D3 D2 D1 A3 B3 C3 D3 E3 F3 G3 H3 C8 C7

REQUIRED READING:Be familiar with the following terminology

From G-P ( in Alphabetical order)( Starting at “GAMBIT” and finishing at “PUSH”)

http://en.wikipedia.org/wiki/Patzer

Page 43: C SC 483 Chess and AI: Computation and Cognitionelmo.sbs.arizona.edu/sandiway/CSC483/lecture3.pdf · A4 B4 C4 D4 E4 F4 G4 H4 D8 D7 D6 D5 D4 D3 D2 D1 A3 B3 C3 D3 E3 F3 G3 H3 C8 C7

Quiz Time