Class: Neuro::Display::NeuroGUI

Inherits:
Object
  • Object
show all
Defined in:
lib/neuro/display.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(max_height, network) ⇒ NeuroGUI

Returns a new instance of NeuroGUI.



343
344
345
346
347
348
349
# File 'lib/neuro/display.rb', line 343

def initialize(max_height, network)
  @network = network
  @observed_network = ObservableNetwork.new(network)
  Gtk.init
  @main_window = MainWindow.new(max_height, @observed_network)
  @main_window.show_all
end

Instance Attribute Details

#observed_networkObject (readonly)

Returns the value of attribute observed_network.



351
352
353
# File 'lib/neuro/display.rb', line 351

def observed_network
  @observed_network
end

Instance Method Details

#startObject



353
354
355
356
357
358
359
360
361
362
363
364
# File 'lib/neuro/display.rb', line 353

def start
  @observed_network.add_listener do |s, m, r, a|
    case m
    when :decide
      @main_window.draw_network(a[0], r)
    when :learn
      d = @network.decide a[0]
      @main_window.draw_network(a[0], d)
    end
  end
  Thread.new { Gtk.main }
end