Advertisement
Guest User

Untitled

a guest
Jan 17th, 2017
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. Assignment name : checkmate
  2. Expected files : *.c, *.h
  3. Allowed functions: write, malloc, free
  4. --------------------------------------------------------------------------------
  5.  
  6. Write a program who takes rows of a chessboard in argument and check if your
  7. King is in a check position.
  8.  
  9. Chess is played on a chessboard, a squared board of 8-squares length with
  10. specific pieces on it : King, Queen, Bishop, Knight, Rook and Pawns.
  11. For this exercice, you will only play with Pawns, Bishops, Rooks and Queen...
  12. and obviously a King.
  13.  
  14. Each piece have a specific method of movement, and all patterns of capture are
  15. detailled in the examples.txt file.
  16.  
  17. A piece can capture only the first ennemy piece it founds on its capture
  18. patterns.
  19.  
  20. The board have a variable size but will remains a square. There's only one King
  21. and all other pieces are against it. All other characters except those used for
  22. pieces are considered as empty squares.
  23.  
  24. The King is considered as in a check position when an other enemy piece can
  25. capture it. When it's the case, you will print "Success" on the standard output
  26. followed by a newline, otherwise you will print "Fail" followed by a newline.
  27.  
  28. If there is no arguments, the program will only print a newline.
  29.  
  30. Examples:
  31.  
  32. $> ./chessmate '..' '.K' | cat -e
  33. Fail$
  34. $> ./chessmate 'R...' '..P.' '.K..' '....' | cat -e
  35. Success$
  36. $> ./chessmate 'R...' 'iheK' '....' 'jeiR' | cat -e
  37. Success$
  38. $> ./chessmate | cat -e
  39. $
  40. $>
  41.  
  42.  
  43.  
  44. Pion / Pawn (P):
  45.  
  46. . . . . . . .
  47. . . . . . . .
  48. . . X . X . .
  49. . . . P . . .
  50. . . . . . . .
  51. . . . . . . .
  52. . . . . . . .
  53.  
  54. Fou / Bishop (B):
  55.  
  56. X . . . . . X
  57. . X . . . X .
  58. . . X . X . .
  59. . . . B . . .
  60. . . X . X . .
  61. . X . . . X .
  62. X . . . . . X
  63.  
  64. Tour / Rook (R):
  65.  
  66. . . . X . . .
  67. . . . X . . .
  68. . . . X . . .
  69. X X X R X X X
  70. . . . X . . .
  71. . . . X . . .
  72. . . . X . . .
  73.  
  74. Dame / Queen (Q)
  75.  
  76. X . . X . . X
  77. . X . X . X .
  78. . . X X X . .
  79. X X X Q X X X
  80. . . X X X . .
  81. . X . X . X .
  82. X . . X . . X
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement