class interface TICTACTOE

creation
   make

feature(s) from TICTACTOE
   --  Constant(s)

   Max_level: INTEGER
      --  Maximum computer intelligence.


feature(s) from TICTACTOE
   --  Reset

   reset
      --  Create/initialise.


feature(s) from TICTACTOE
   --  Option(s)

   set_level (lvl: INTEGER)
      --  Level (1: Easy, Max_level: Difficult).

      require
         valid: lvl > 0 and lvl <= Max_level
      ensure
         done: level = lvl

feature(s) from TICTACTOE
   --  Status

   is_square (col, row: INTEGER): BOOLEAN
      --  Is this (col, row) correct?

      ensure
         done: Result = (col >= 1 and col <= 3 and row >= 1 and row <= 3)

   is_empty (col, row: INTEGER): BOOLEAN
      --  Is this square empty?

      require
         in: is_square(col,row)

   is_user (col, row: INTEGER): BOOLEAN
      --  Is this a user's square?

      require
         in: is_square(col,row)

   is_computer (col, row: INTEGER): BOOLEAN
      --  Is this a computer's square?

      require
         in: is_square(col,row)

   is_finished: BOOLEAN
      --  Finished?


   is_user_winner: BOOLEAN
      --  Who wins?

      require
         ok: is_finished

   is_computer_winner: BOOLEAN
      require
         ok: is_finished

feature(s) from TICTACTOE
   --  Action

   move (col, row: INTEGER)
      --  User plays on (col, row).

      require
         notend: not is_finished;
         ok: is_square(col,row);
         empty: is_empty(col,row)

   computer_move
      --  Computer plays.

      require
         notend: not is_finished

invariant
   board: board /= Void;

end of TICTACTOE