1. Shlomi Fish
  2. Hitori

Commits

shl...@27f4d2be-69b7-b1af-7dc8-71755b09f50e  committed a7cdfbc

Add support for filename input to the GUI.

  • Participants
  • Parent commits ad3c7c2
  • Branches default

Comments (0)

Files changed (2)

File hitori-solver-in-ruby/boards/menneske.no-2.txt

View file
+5*5
+[2] [5] [3] [3] [1]
+[2] [1] [2] [3] [5]
+[1] [3] [1] [2] [4]
+[4] [2] [3] [5] [3]
+[4] [4] [4] [1] [2]

File hitori-solver-in-ruby/gui/qt/hitori-gui.rb

View file
 
 $VERBOSE = true; $:.unshift File.dirname($0)
 
+$board_filename = ARGV.shift
+
 require 'Qt'
 
 class HitoriField < Qt::Widget
 
 class MyHitoriGame
     attr_reader :board, :process
-    def initialize()
+
+    def get_board()
         contents = [
             [2,1,3,2,4],
             [4,5,3,2,2],
             [1,4,3,3,2],
             [2,5,1,4,3]
         ]
+        
+        if ($board_filename)
+            return HitoriSolver::Board.parse(File.read($board_filename))
+        else
+            return [5,5,contents]
+        end
+    end
 
-        @board = HitoriSolver::Board.new(5, 5, contents)
+    def initialize()
+
+        @board = HitoriSolver::Board.new(*get_board())
         @process = HitoriSolver::Process.new(@board)
     end