XiangqiGame

Write a class named XiangqiGame for playing an abstract board game called xiangqi. Please read the “Board”, “Rules”, and “Pieces” sections on the Wikipedia page. You do not have to implement the rules regarding perpetual check or chasing. You do need to correctly handle stalemate. You also need to correctly handle all piece-specific rules, e.g. generals aren’t allowed to “see” each other, horses can be blocked, elephants can’t cross the river, etc.

A general is in check if it could be captured on the opposing player’s next move. A player cannot make a move that puts or leaves their general in check. The Wikipedia page says “The game ends when one player captures the other’s general”, but it’s more accurate to say that it ends when one player checkmates the other’s general. You don’t actually capture a general, instead you have to put it in such a position that it cannot escape being in check, meaning that no matter what, it could be captured on the next move. This works the same as in chess, if you’re familiar with that game.

Red is the starting player.

Locations on the board will be specified using “algebraic notation”, with columns labeled a-i and rows labeled 1-10, with row 1 being the Red side and row 10 the Black side.

You’re not required to print the board, but you will probably find it very useful for testing purposes.

Your XiangqiGame class must include the following:

  • An init method that initializes any data members.
  • A method called get_game_state that just returns ‘UNFINISHED’, ‘RED_WON’ or ‘BLACK_WON’.
  • A method called is_in_check that takes as a parameter either ‘red’ or ‘black’ and returns True if that player is in check, but returns False otherwise.
  • A method called make_move that takes two parameters – strings that represent the square moved from and the square moved to. For example, make_move(‘b3’, ‘b10’). If the square being moved from does not contain a piece belonging to the player whose turn it is, or if the indicated move is not legal, or if the game has already been won, then it should just return False. Otherwise it should make the indicated move, remove any captured piece, update the game state if necessary, update whose turn it is, and return True.

Feel free to add whatever other classes, methods, or data members you want. All data members must be private. Every class should have an init method that initializes all of the data members for that class.

Here’s a very simple example of how the class could be used:

game = XiangqiGame() move_result = game.make_move(‘c1’, ‘e3’) black_in_check = game.is_in_check(‘black’) game.make_move(‘e7’, ‘e6’) state = game.get_game_state()

The file must be named: XiangqiGame.py

No Imports allowed.

Hide 

Calculate the price of your order

Simple Order Process

Fill in the Order Form

Share all the assignment information. Including the instructions, provided reading materials, grading rubric, number of pages, the required formatting, deadline, and your academic level. Provide any information and announcements shared by the professor. Choose your preferred writer if you have one.

Get Your Order Assigned

Once we receive your order form, we will select the best writer from our pool of experts to fit your assignment.

Share More Data if Needed

You will receive a confirmation email when a writer has been assigned your task. The writer may contact you if they need any additional information or clarifications regarding your task

Let Our Essay Writer Do Their Job

Once you entrust us with your academic task, our skilled writers embark on creating your paper entirely from the ground up. Through rigorous research and unwavering commitment to your guidelines, our experts meticulously craft every aspect of your paper. Our process ensures that your essay is not only original but also aligned with your specific requirements, making certain that the final piece surpasses your expectations.

Quality Checks and Proofreading

Upon the completion of your paper, it undergoes a meticulous review by our dedicated Quality and Proofreading department. This crucial step ensures not only the originality of the content but also its alignment with the highest academic standards. Our seasoned experts conduct thorough checks, meticulously examining every facet of your paper, including grammar, structure, coherence, and proper citation. This comprehensive review process guarantees that the final product you receive not only meets our stringent quality benchmarks but also reflects your dedication to academic excellence.

Review and Download the Final Draft

If you find that any part of the paper does not meet the initial instructions, send it back to us with your feedback, and we will make the necessary adjustments.