Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Program Chessboard_Game;
- Uses wincrt;
- Type
- Player = (Black, White);
- Chess_Piece = ( Empty , WPawn, WKnight, WBishop, WRook, WQueen, WKing,
- BPawn, BKnight, BBishop, BRook, BQueen, BKing);
- Chessboard = Array [1..8,1..8] of Chess_Piece;
- Var
- CB : Chessboard;
- Procedure Refill_Game(var T : Chessboard);
- var i, j : integer;
- Begin
- for i := 1 to 8 Do
- Begin
- for j := 1 to 8 Do
- Begin
- // Black chess pieces
- if ( i = 1 ) and ( ( j = 1 ) or ( j = 8 ) ) Then
- T[i][j] := BRook
- else if ( i = 1 ) and ( ( j = 2 ) or ( j = 7 ) ) Then
- T[i][j] := BKnight
- else if ( i = 1 ) and ( ( j = 3 ) or ( j = 6 ) ) Then
- T[i][j] := BBishop
- else if ( i = 1 ) and ( j = 4 ) Then
- T[i][j] := BQueen
- else if ( i = 1 ) and ( j = 5 ) Then
- T[i][j] := BKing
- else if ( i = 2 ) Then
- T[i][j] := BPawn
- // White Chess Pieces chess pieces
- else if ( i = 7 ) Then
- T[i][j] := WPawn
- else if ( i = 8 ) and ( ( j = 1 ) or ( j = 8 ) ) Then
- T[i][j] := WRook
- else if ( i = 8 ) and ( ( j = 2 ) or ( j = 7 ) ) Then
- T[i][j] := WKnight
- else if ( i = 8 ) and ( ( j = 3 ) or ( j = 6 ) ) Then
- T[i][j] := WBishop
- else if ( i = 8 ) and ( j = 4 ) Then
- T[i][j] := WQueen
- else if ( i = 8 ) and ( j = 5 ) Then
- T[i][j] := WKing
- Else
- T[i][j] := Empty;
- End;
- End;
- End;
- Procedure Show_Game(T : Chessboard);
- var i, j : integer;
- Begin
- for i := 1 to 8 Do
- Begin
- writeln('');
- for j := 1 to 8 Do
- Begin
- case T[i][j] of
- WPawn .. WKing : write('WHITE ');
- BPawn .. BKing : write('BLACK ');
- Else
- write('EMPTY ');
- End;
- End;
- End;
- End;
- Begin
- Refill_Game(CB);
- Show_Game(CB);
- End.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement