Class: SGF::More::StmDotConverter

Inherits:
Object
  • Object
show all
Defined in:
lib/sgf/more/stm_dot_converter.rb

Constant Summary collapse

STATE_PROPERTIES =
{
  SGF::SGFStateMachine::STATE_BEGIN => {
    :shape => 'circle', :fillcolor => '#44ff44', :style => 'filled'
  },
  SGF::SGFStateMachine::STATE_GAME_BEGIN => {
  },
  SGF::SGFStateMachine::STATE_VAR_BEGIN => {
  },
  SGF::SGFStateMachine::STATE_VAR_END => {
  },
  SGF::SGFStateMachine::STATE_GAME_END => {
    :label => 'end', :shape => 'doublecircle', :fillcolor => '#44ff44', :style => 'filled'
  },
  SGF::SGFStateMachine::STATE_INVALID => {
    :label => 'error', :shape => 'octagon', :fillcolor => '#ff4444', :style => 'filled'
  },
}
EDGE_PROPERTIES =
{
  "begin:game_begin" => {
    :weight => 100
  },
  "game_begin:game_node" => {
    :weight => 100
  },
  "game_node:prop_name_begin" => {
    :weight => 100
  },
  "prop_name_begin:prop_name" => {
    :weight => 100
  },
  "prop_name:value_begin" => {
    :weight => 100
  },
  "value_begin:value" => {
    :weight => 100
  },
  "value:value_end" => {
    :weight => 100
  },
  "value_end:var_end" => {
    :weight => 100
  },
  "var_end:game_node" => {
    :weight => 100
  },
  "var_end:game_end" => {
    :weight => 100
  },
}

Instance Method Summary collapse

Instance Method Details

#process(stm) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/sgf/more/stm_dot_converter.rb', line 56

def process stm
  s = "digraph SGF_STATE_MACHINE{"
  s << graph_attributes
  s << create_node_for_state(stm.start_state)

  stm.transitions.each do |start_state, transitions|
    transitions.each do |transition|
      s << create_edge_for_transition(start_state, transition)
    end
  end

  s << "}\n"
  s
end