with Io;
package body Square is
    -- definition of the actual 'checker-board' as a vector (just for
    --      the fun of it) with constant specification
    Size_2 : constant Positive := Size ** 2;
    subtype Edge is Natural range 0 .. Size ** 2 - 1;
    Board : array (Edge) of Natural := (others => 0);
    -- position of the cursor
    X : Edge := Size_2 / 2;

    procedure Go_To_Center is
    begin
        X := Size_2 / 2;
    end Go_To_Center;

    procedure Go (Which_Direction : in Direction) is
    begin
        case Which_Direction is
            when North | North_East | North_West =>
                X := (X - Size) mod Size_2;
            when South | South_East | South_West =>
                X := (X + Size) mod Size_2;
            when others =>
                null;
        end case;
        case Which_Direction is
            when East | North_East | South_East =>
                X := ((X / Size) * Size + (((X mod Size) + 1) mod Size));
            when West | North_West | South_West =>
                X := ((X / Size) * Size + (((X mod Size) - 1) mod Size));
            when others =>
                null;
        end case;
    end Go;

    function Is_Already_Occupied return Boolean is
    begin
        return Board (X) > 0;
    end Is_Already_Occupied;

    procedure Deposit (Token : Positive) is
    begin
        Board (X) := Token;
    end Deposit;

    procedure Display is
    begin
        for X in Edge loop
            if X mod Size = 0 then
                Io.New_Line;
            end if;
            Io.Put (Board (X), Width => 4);
        end loop;  
        Io.New_Line;
    end Display;
end Square;