Pseudo Code Chess

Asked

Viewed 243 times

1

They put a challenge to me to solve through pseudocode:

A chess board with only the King and Queen. What is the minimum and maximum number of moves to checkmate the King?

Black King, White Queen

I know the rules of chess and I’ve played a few times, so until I say I can play chess, it’s a long way.

  • A king and a black queen and also a king and a white queen?

  • They did not impose the colors, but by the way there will be differences in the colors of the King and Queen?

  • 2

    I ask because it interferes, if both are with a queen the number of moves is X, if only one color has this advantage, the number of moves and the other. One place to simulate is https://nextchessmove.com/ but if the layout is the initial one (https://nextchessmove.com/?Fen=3qk3%2F8%2F8%2F8%2F8%2F8%2F8%2F8%2F3QK3+w+-++0+1&flipped=false), then one queen captures the other, and in 2 moves you end up with the kings, then it is impossible to give mate

  • 2

    You have to detail your problem better, it is full of gap for interpretations.

  • Cenário 1: Rei Preto, Rainha Branca Cenário 2: Rei Branco, Rainha Preta You realize there are no differences in the calculations of the two scenarios, don’t you? In both cases have a king and a queen enemies, the color doesn’t matter.

  • Edited post. Thanks @Math. I only have this information. It is possible to elaborate a resolution to this problem?

  • 3

    It is not possible to solve only with this information - it is also necessary to know the initial position of the pieces. And are you sure it’s only black king / white queen? Wouldn’t it be black king / king + white queen (or vice versa)? If a color doesn’t have the king, then by definition of the rules of chess it’s already lost.

  • Only Black King and White Queen. In order for the King to have more possible moves he must be in the middle of the board, right?

  • 3

    If it is only the white queen against the black king (which goes against the rules of chess), then the queen cannot give the checkmate alone in the king. Maybe there’s a Sthalemate ("drowned king"), or the game will continue until the time runs out (or the patience of the players).

Show 4 more comments

1 answer

14


As the question is formulated, there is not enough information to solve the problem. But assuming the following:

  • They are not only a king and a queen (of opposite colors), but a king of one color and a pair (king + queen) of the other color
  • To simplify the explanation below, assuming there is a black king (K), and a king (k) and a white queen (q)

The minimum number of moves is zero - if the initial board setting is already in a checkmate state. For example (instead of black):

/-------------------------------\
|   |   |   |   | K |   |   | q |
|-------------------------------|
|   |   |   |   |   |   |   |   |
|-------------------------------|
|   |   |   |   | k |   |   |   |
|-------------------------------|
|   |   |   |   |   |   |   |   |
|-------------------------------|
|   |   |   |   |   |   |   |   |
|-------------------------------|
|   |   |   |   |   |   |   |   |
|-------------------------------|
|   |   |   |   |   |   |   |   |
|-------------------------------|
|   |   |   |   |   |   |   |   |
\-------------------------------/

Or one, if it’s a move before that.

The maximum number will depend on the strategy the player of the white pieces is using to corner the black king. If the player has no strategy and moves the tiles randomly, the maximum number may tend to infinity.

There are some end-of-game strategies for this scenario (K vs k+q). If the player has used one of them (for example, http://www.wikihow.com/Mate-With-King-and-Queen-Vs-King), the maximum number will depend on where the three pieces are initially on the board - as the white king needs to get "close" to the black, if he is farther away the number of moves will be higher. But at most, the number of moves before the checkmate will be 10.

  • 7

    +1, It’s just a shame that the explanation did not use the mario chess :'(

  • 5

    @Math, you mean I should use this board: http://imgur.com/AczKFFFE?

  • Perfect! They’ve cornered the Owser!!

  • Thanks for the @carlosfigueira explanation.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.