Class: SGF::Model::Game

Inherits:
Object
  • Object
show all
Includes:
Constants, SGFHelper
Defined in:
lib/sgf/model/game.rb

Constant Summary

Constants included from Constants

Constants::BLACK, Constants::DEFAULT_BOARD_SIZE, Constants::DEFAULT_KOMI, Constants::NODE_MOVE, Constants::NODE_PASS, Constants::NODE_SETUP, Constants::POSITIONS, Constants::WEIQI, Constants::WHITE

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from SGFHelper

#move_to_sgf, #to_label, #to_position, #to_position_array, #xy_to_sgf_pos

Constructor Details

#initializeGame

Returns a new instance of Game.



14
15
16
17
18
19
# File 'lib/sgf/model/game.rb', line 14

def initialize
  @game_type   = WEIQI
  @board_size  = DEFAULT_BOARD_SIZE
  @handicap    = 0
  @komi        = DEFAULT_KOMI
end

Instance Attribute Details

#annotationObject

Returns the value of attribute annotation.



7
8
9
# File 'lib/sgf/model/game.rb', line 7

def annotation
  @annotation
end

#black_playerObject

Returns the value of attribute black_player.



7
8
9
# File 'lib/sgf/model/game.rb', line 7

def black_player
  @black_player
end

#black_rankObject

Returns the value of attribute black_rank.



7
8
9
# File 'lib/sgf/model/game.rb', line 7

def black_rank
  @black_rank
end

#black_teamObject

Returns the value of attribute black_team.



7
8
9
# File 'lib/sgf/model/game.rb', line 7

def black_team
  @black_team
end

#board_sizeObject

Returns the value of attribute board_size.



7
8
9
# File 'lib/sgf/model/game.rb', line 7

def board_size
  @board_size
end

#commentObject

Returns the value of attribute comment.



7
8
9
# File 'lib/sgf/model/game.rb', line 7

def comment
  @comment
end

#eventObject

Returns the value of attribute event.



7
8
9
# File 'lib/sgf/model/game.rb', line 7

def event
  @event
end

#game_typeObject

Returns the value of attribute game_type.



7
8
9
# File 'lib/sgf/model/game.rb', line 7

def game_type
  @game_type
end

#handicapObject

Returns the value of attribute handicap.



7
8
9
# File 'lib/sgf/model/game.rb', line 7

def handicap
  @handicap
end

#komiObject

Returns the value of attribute komi.



7
8
9
# File 'lib/sgf/model/game.rb', line 7

def komi
  @komi
end

#nameObject

Returns the value of attribute name.



7
8
9
# File 'lib/sgf/model/game.rb', line 7

def name
  @name
end

#overtime_ruleObject

Returns the value of attribute overtime_rule.



7
8
9
# File 'lib/sgf/model/game.rb', line 7

def overtime_rule
  @overtime_rule
end

#placeObject

Returns the value of attribute place.



7
8
9
# File 'lib/sgf/model/game.rb', line 7

def place
  @place
end

#played_onObject

Returns the value of attribute played_on.



7
8
9
# File 'lib/sgf/model/game.rb', line 7

def played_on
  @played_on
end

#programObject

Returns the value of attribute program.



7
8
9
# File 'lib/sgf/model/game.rb', line 7

def program
  @program
end

#resultObject

Returns the value of attribute result.



7
8
9
# File 'lib/sgf/model/game.rb', line 7

def result
  @result
end

#roundObject

Returns the value of attribute round.



7
8
9
# File 'lib/sgf/model/game.rb', line 7

def round
  @round
end

#ruleObject

Returns the value of attribute rule.



7
8
9
# File 'lib/sgf/model/game.rb', line 7

def rule
  @rule
end

#sourceObject

Returns the value of attribute source.



7
8
9
# File 'lib/sgf/model/game.rb', line 7

def source
  @source
end

#time_ruleObject

Returns the value of attribute time_rule.



7
8
9
# File 'lib/sgf/model/game.rb', line 7

def time_rule
  @time_rule
end

#white_playerObject

Returns the value of attribute white_player.



7
8
9
# File 'lib/sgf/model/game.rb', line 7

def white_player
  @white_player
end

#white_rankObject

Returns the value of attribute white_rank.



7
8
9
# File 'lib/sgf/model/game.rb', line 7

def white_rank
  @white_rank
end

#white_teamObject

Returns the value of attribute white_team.



7
8
9
# File 'lib/sgf/model/game.rb', line 7

def white_team
  @white_team
end

Instance Method Details

#misc_propertiesObject



21
22
23
# File 'lib/sgf/model/game.rb', line 21

def misc_properties
  @misc_properties ||= {}
end

#movesObject



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/sgf/model/game.rb', line 38

def moves
  moves = 0
  
  node = root_node
  while node
    moves = node.move_no
    node = node.children[0]
  end
  
  moves
end

#root_nodeObject



30
31
32
# File 'lib/sgf/model/game.rb', line 30

def root_node
  @root_node ||= Node.new(nil)
end