+
Point of view
All features
class KNIGHT
Summary
The classic KNIGHT problem on a N times N square chessboard. The knight have to pass on all places of the chessboard once a time. For instance, here is solution for a 7 X 7 chessboard, knight starting at position <1,1>:
           1   28   37   24    3   26   17
          36   39    2   27   18   11    4
          29   42   23   38   25   16    9
          40   35   30   19   10    5   12
          43   22   41   32   15    8   47
          34   31   20   45   48   13    6
          21   44   33   14    7   46   49
Direct parents
Insert list: ARGUMENTS
Overview
Creation features
{ANY}
Features
{}
{ANY}
{ANY}
{}
Implementation of ARGUMENTS (do not use directly):
{}
make
effective procedure
{}
chess_minimum: INTEGER_32
is 3
constant attribute
{}
chess_maximum: INTEGER_32
is 24
constant attribute
{}
chessboard: ARRAY2[INTEGER_32]
writable attribute
{}
nb_tries: INTEGER_32
writable attribute
{}
line_move: FAST_ARRAY[INTEGER_32]
once function
{}
column_move: FAST_ARRAY[INTEGER_32]
once function
{}
knight (size: INTEGER_32, line: INTEGER_32, column: INTEGER_32)
effective procedure
{}
require
  • size >= 3
  • 1 <= line
  • line <= size
  • 1 <= column
  • column <= size
solution (line: INTEGER_32, column: INTEGER_32): BOOLEAN
effective function
{}
try (line: INTEGER_32, column: INTEGER_32, value: INTEGER_32): BOOLEAN
effective function
{}
Try to place the knight by used cross back-tracking method.
ask (s: STRING, min: INTEGER_32, max: INTEGER_32): INTEGER_32
effective function
{}
Ask for question s until the answer is in range min max.
print_on (file: OUTPUT_STREAM)
effective procedure
{ANY}
Display the chessboard.
require
  • file.is_connected
argument_count: INTEGER_32
effective function
{ANY}
Number of arguments given to command that started system execution (command name does not count).
ensure
  • Result >= 0
argument (i: INTEGER_32): STRING
effective function
{ANY}
i th argument of command that started system execution Gives the command name if i is 0.
require ensure
  • Result /= Void
command_name: STRING
effective function
{ANY}
command_arguments: FAST_ARRAY[STRING]
frozen
once function
{}
Give access to arguments command line including the command name at index 0.
This is a once function, so you can modify command-line arguments! (NOTE: just be sure not to remove the first argument, although you may change it)
ensure
  • not Result.is_empty
se_argc: INTEGER_32
{}
To implement command_arguments
se_argv (i: INTEGER_32): STRING
{}
To implement command_arguments