Contenu du cours

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 |


Évaluation
0 0

Il n'y a aucun commentaire pour le moment.

pour être le premier à laisser un commentaire.

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