SHARE
TWEET

Untitled

a guest Feb 27th, 2020 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Program Chessboard_Game;
  2. Uses wincrt;
  3. Type
  4.     Player = (Black, White);
  5.     Chess_Piece = ( Empty , WPawn, WKnight, WBishop, WRook, WQueen, WKing,
  6.     BPawn, BKnight, BBishop, BRook, BQueen, BKing);
  7.     Chessboard = Array [1..8,1..8] of Chess_Piece;
  8. Var
  9.     CB : Chessboard;
  10. Procedure Refill_Game(var T : Chessboard);
  11. var i, j : integer;
  12. Begin
  13.     for i := 1 to 8 Do
  14.     Begin
  15.         for j := 1 to 8 Do
  16.         Begin
  17.             // Black chess pieces
  18.             if ( i = 1 ) and ( ( j = 1 ) or ( j = 8 ) ) Then
  19.                 T[i][j] := BRook
  20.             else if ( i = 1 ) and ( ( j = 2 ) or ( j = 7 ) ) Then
  21.                 T[i][j] := BKnight
  22.             else if ( i = 1 ) and ( ( j = 3 ) or ( j = 6 ) ) Then
  23.                 T[i][j] := BBishop
  24.             else if ( i = 1 ) and ( j = 4 ) Then
  25.                 T[i][j] := BQueen
  26.             else if ( i = 1 ) and ( j = 5 ) Then
  27.                 T[i][j] := BKing
  28.             else if ( i = 2 ) Then
  29.                 T[i][j] := BPawn
  30.             // White Chess Pieces chess pieces
  31.             else if ( i = 7 ) Then
  32.                 T[i][j] := WPawn
  33.             else if ( i = 8 ) and ( ( j = 1 ) or ( j = 8 ) ) Then
  34.                 T[i][j] := WRook
  35.             else if ( i = 8 ) and ( ( j = 2 ) or ( j = 7 ) ) Then
  36.                 T[i][j] := WKnight
  37.             else if ( i = 8 ) and ( ( j = 3 ) or ( j = 6 ) ) Then
  38.                 T[i][j] := WBishop
  39.             else if ( i = 8 ) and ( j = 4 ) Then
  40.                 T[i][j] := WQueen
  41.             else if ( i = 8 ) and ( j = 5 ) Then
  42.                 T[i][j] := WKing
  43.             Else
  44.                 T[i][j] := Empty;
  45.         End;
  46.     End;
  47. End;
  48. Procedure Show_Game(T : Chessboard);
  49. var i, j : integer;
  50. Begin
  51.     for i := 1 to 8 Do
  52.     Begin
  53.         writeln('');
  54.         for j := 1 to 8 Do
  55.         Begin
  56.             case T[i][j] of
  57.                 WPawn .. WKing : write('WHITE ');
  58.                 BPawn .. BKing : write('BLACK ');
  59.                 Else
  60.                     write('EMPTY ');
  61.                 End;
  62.         End;
  63.     End;
  64. End;
  65. Begin
  66.     Refill_Game(CB);
  67.     Show_Game(CB);
  68. End.
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top