Class: Rubykon::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/rubykon/cli.rb

Constant Summary collapse

EXIT =
/exit/i
CHAR_LABELS =
GTPCoordinateConverter::X_CHARS
X_LABEL_PADDING =
' '.freeze * 4
Y_LABEL_WIDTH =
3
GTP_COORDINATE =
/^[A-Z]\d\d?$/
MOVE_CONSIDERATIONS_COUNT =
10

Instance Method Summary collapse

Constructor Details

#initialize(output = $stdout, input = $stdin) ⇒ CLI

Returns a new instance of CLI.



11
12
13
14
15
16
17
# File 'lib/rubykon/cli.rb', line 11

def initialize(output = $stdout, input = $stdin)
  @output         = output
  @input          = input
  @state          = :init
  @move_validator = MoveValidator.new
  @root           = nil
end

Instance Method Details

#startObject



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/rubykon/cli.rb', line 19

def start
  @output.puts 'Please enter a board size (common sizes are 9, 13, and 19)'
  size = get_digit_input
  @output.puts <<-PLAYOUTS
Please enter the number of playouts you'd like rubykon to make!
More playouts means rubykon is stronger, but also takes longer.
For 9x9 10000 is an acceptable value, for 19x19 1000 already take a long time (but still plays bad).
  PLAYOUTS
  playouts = get_digit_input
  init_game(size, playouts)
  game_loop
end