Course content

Chess or tic-tac-toe

Implement a program that simulates a complex game like chess or tic-tac-toe. Allow two players to make their moves, validate the moves, and check for a win or draw condition.


Chess Game:

Player 1 (White): John

Player 2 (Black): Jane


Initial Board:

| R | N | B | Q | K | B | N | R |

| P | P | P | P | P | P | P | P |

| . | . | . | . | . | . | . | . |

| . | . | . | . | . | . | . | . |

| . | . | . | . | . | . | . | . |

| . | . | . | . | . | . | . | . |

| p | p | p | p | p | p | p | p |

| r | n | b | q | k | b | n | r |


John's move (White): e2 to e4


Updated Board:

| R | N | B | Q | K | B | N | R |

| P | P | P | P | P | P | P | P |

| . | . | . | . | . | . | . | . |

| . | . | . | . | . | . | . | . |

| . | . | . | . | . | . | . | . |

| . | . | . | . | . | . | . | . |

| p | p | p | p | p | p | p | p |

| r | n | b | q | k | b | n | r |


Jane's move (Black): e7 to e5


Updated Board:

| R | N | B | Q | K | B | N | R |

| P | P | P | P | P | P | P | P |

| . | . | . | . | . | . | . | . |

| . | . | . | . | . | . | . | . |

| . | . | . | . | . | . | . | . |

| . | . | . | . | . | . | . | . |

| p | p | p | p | p | p | p | p |

| r | n | b | q | k | b | n | r |


Implement a program that simulates a complex game like chess or tic-tac-toe. Allow two players to make their moves, validate the moves, and check for a win or draw condition.


Chess Game:

Player 1 (White): John

Player 2 (Black): Jane


Initial Board:

| R | N | B | Q | K | B | N | R |

| P | P | P | P | P | P | P | P |

| . | . | . | . | . | . | . | . |

| . | . | . | . | . | . | . | . |

| . | . | . | . | . | . | . | . |

| . | . | . | . | . | . | . | . |

| p | p | p | p | p | p | p | p |

| r | n | b | q | k | b | n | r |


John's move (White): e2 to e4


Updated Board:

| R | N | B | Q | K | B | N | R |

| P | P | P | P | P | P | P | P |

| . | . | . | . | . | . | . | . |

| . | . | . | . | . | . | . | . |

| . | . | . | . | . | . | . | . |

| . | . | . | . | . | . | . | . |

| p | p | p | p | p | p | p | p |

| r | n | b | q | k | b | n | r |


Jane's move (Black): e7 to e5


Updated Board:

| R | N | B | Q | K | B | N | R |

| P | P | P | P | P | P | P | P |

| . | . | . | . | . | . | . | . |

| . | . | . | . | . | . | . | . |

| . | . | . | . | . | . | . | . |

| . | . | . | . | . | . | . | . |

| p | p | p | p | p | p | p | p |

| r | n | b | q | k | b | n | r |


Rating
0 0

There are no comments for now.

to be the first to leave a comment.

1. What data structure is used to represent the chessboard in the code?