OSDN Git Service

Fixed case... when... syntax for Ruby 1.9.3.
[shogi-server/shogi-server.git] / shogi_server / board.rb
index d7f9466..d2b304b 100644 (file)
@@ -25,6 +25,22 @@ class WrongMoves < ArgumentError; end
 
 class Board
   
+  # Initial board setup. 
+  # The string ends with '+', not a line break.
+  #
+  INITIAL_HIRATE_POSITION = (<<-EOF).chomp
+P1-KY-KE-GI-KI-OU-KI-GI-KE-KY
+P2 * -HI *  *  *  *  * -KA * 
+P3-FU-FU-FU-FU-FU-FU-FU-FU-FU
+P4 *  *  *  *  *  *  *  *  * 
+P5 *  *  *  *  *  *  *  *  * 
+P6 *  *  *  *  *  *  *  *  * 
+P7+FU+FU+FU+FU+FU+FU+FU+FU+FU
+P8 * +KA *  *  *  *  * +HI * 
+P9+KY+KE+GI+KI+OU+KI+GI+KE+KY
++
+EOF
+
   # Split a moves line into an array of a move string.
   # If it fails to parse the moves, it raises WrongMoves.
   # @param moves a moves line. Ex. "+776FU-3334Fu"
@@ -42,6 +58,7 @@ class Board
     return ret
   end
 
+
   def initialize(move_count=0)
     @sente_hands = Array::new
     @gote_hands  = Array::new
@@ -658,6 +675,8 @@ class Board
     return :normal
   end
 
+  # Return a CSA-styled string notation of the current position.
+  #
   def to_s
     a = Array::new
     y = 1
@@ -694,6 +713,14 @@ class Board
     a.push("%s\n" % [@teban ? "+" : "-"])
     return a.join
   end
+
+  # Return a CSA-styled string notation of the initial position.
+  #
+  def initial_string
+    tmp_board = self.class.new
+    tmp_board.initial
+    return tmp_board.to_s
+  end
 end
 
 end # ShogiServer