@sente.game = self
@gote.game = self
- @last_move = @board.initial_moves.empty? ? "" : "%s,T1" % [@board.initial_moves.last]
+ @last_move = ""
+ unless @board.initial_moves.empty?
+ last_move = @board.initial_moves.last
+ case last_move
+ when Array
+ @last_move = last_move.join(",")
+ when String
+ @last_move = "%s,T1" % [last_move]
+ end
+ end
@current_turn = @board.initial_moves.size
@sente.status = "agree_waiting"
unless @board.initial_moves.empty?
@fh.puts "'buoy game starting with %d moves" % [@board.initial_moves.size]
@board.initial_moves.each do |move|
- @fh.puts move
- @fh.puts "T1"
+ case move
+ when Array
+ @fh.puts move[0]
+ @fh.puts move[1]
+ when String
+ @fh.puts move
+ @fh.puts "T1"
+ end
end
end
end
END Time
BEGIN Position
#{@board.initial_string.chomp}
-#{@board.initial_moves.collect {|m| m + ",T1"}.join("\n")}
+#{@board.initial_moves.collect do |m|
+ case m
+ when Array
+ m.join(",")
+ when String
+ m + ",T1"
+ end
+end.join("\n")}
END Position
END Game_Summary
EOM
return false
end
+
+ # Read the .csa file and returns an array of moves and times.
+ # ex. [["+7776FU","T2"], ["-3334FU","T5"]]
+ #
+ def read_moves
+ ret = []
+ IO.foreach(@logfile) do |line|
+ if /^[\+\-]\d{4}[A-Z]{2}/ =~ line
+ ret << [line.chomp]
+ elsif /^T\d*/ =~ line
+ ret[-1] << line.chomp
+ end
+ end
+ return ret
+ end
private