The program contains some type definitions that can be used in a program for playing noughts and crosses (also known as tic-tac-toe). gamePos2 describes a completed position where one player has won
I am trying to change the record type GamePos to be a union type supporting two variants: a position of a completed game and a position of a game in progress.
Feel free to ask any questions so I can elaborate on my problem
type GamePos is
record
board : TTTBoard;
turn : Player;
value : Float;
end record;
procedure Put_Pos(pos : GamePos) is
begin
Put_Board(pos.board);
Put("Player to make the next move: ");
Put(pos.turn);
Put_Line("");
Put("Estimated advantage of player X over player O is: ");
Put(pos.value, 0, 0, 0);
Put_Line("");
end Put_Pos;
gamePos1 : GamePos
:= (board =>
((X, X, O),
(O, B, X),
(O, B, B)),
turn => Player_X,
value => 0.0);
gamePos2 : GamePos
:= (pos_variant => WON, -- the discriminant
board =>
((X, X, O),
(O, X, X),
(O, O, X)),
winner => Player_X);
begin
Put_Pos(gamePos1);
Put_Line("");
Put_Pos(gamePos2);
end TTT;