OSDN Git Service

The Buoy behaivor is changed.
authordaigo <beatles@users.sourceforge.jp>
Sat, 4 Sep 2010 06:06:48 +0000 (15:06 +0900)
committerDaigo Moriwaki <daigo@debian.org>
Sat, 4 Sep 2010 06:06:48 +0000 (15:06 +0900)
Starting a buoy game, players are notified a starting game
position with the initial position and moves, instread of a
targeting position.

changelog
shogi_server/board.rb
shogi_server/game.rb
test/TC_game.rb

index 71c5d92..6d96ca3 100644 (file)
--- a/changelog
+++ b/changelog
@@ -1,3 +1,12 @@
+2010-09-04  Daigo Moriwaki <daigo at debian dot org>
+
+       * [shogi-server]
+         - shogi_server/board.rb, shogi_server/game.rb: The Buoy behaivor
+           is changed.
+           + Starting a buoy game, players are notified a starting game
+             position with the initial position and moves, instread of a
+             targeting position.
+
 2010-08-05  Daigo Moriwaki <daigo at debian dot org>
 
        * [shogi-server]
index d7f9466..be22ef1 100644 (file)
@@ -25,6 +25,22 @@ class WrongMoves < ArgumentError; end
 
 class Board
   
+  # Initial board setup. 
+  # The string ends with '+', not a line break.
+  #
+  INITIAL_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
index e6d58d9..5f7cd0e 100644 (file)
@@ -370,11 +370,14 @@ Byoyomi:#{@byoyomi}
 Least_Time_Per_Move:#{Least_Time_Per_Move}
 END Time
 BEGIN Position
-#{@board.to_s.chomp}
+#{Board::INITIAL_POSITION}
+#{@board.initial_moves.collect {|m| m + ",T1"}.join("\n")}
 END Position
 END Game_Summary
 EOM
-    return str
+    # An empty @board.initial_moves causes an empty line, which should be
+    # eliminated.
+    return str.gsub("\n\n", "\n")
   end
 
   def prepared_expire?
index 09ab2a7..a2b8366 100644 (file)
@@ -162,11 +162,12 @@ P2 * -HI *  *  *  *  * -KA *
 P3-FU-FU-FU-FU-FU-FU-FU-FU-FU
 P4 *  *  *  *  *  *  *  *  * 
 P5 *  *  *  *  *  *  *  *  * 
-P6 *  * +FU *  *  *  *  *  * 
-P7+FU+FU * +FU+FU+FU+FU+FU+FU
+P6 *  *  *  *  *  *  *  *  * 
+P7+FU+FU+FU+FU+FU+FU+FU+FU+FU
 P8 * +KA *  *  *  *  * +HI * 
 P9+KY+KE+GI+KI+OU+KI+GI+KE+KY
--
++
++7776FU,T1
 END Position
 END Game_Summary
 EOF
@@ -196,11 +197,12 @@ P2 * -HI *  *  *  *  * -KA *
 P3-FU-FU-FU-FU-FU-FU-FU-FU-FU
 P4 *  *  *  *  *  *  *  *  * 
 P5 *  *  *  *  *  *  *  *  * 
-P6 *  * +FU *  *  *  *  *  * 
-P7+FU+FU * +FU+FU+FU+FU+FU+FU
+P6 *  *  *  *  *  *  *  *  * 
+P7+FU+FU+FU+FU+FU+FU+FU+FU+FU
 P8 * +KA *  *  *  *  * +HI * 
 P9+KY+KE+GI+KI+OU+KI+GI+KE+KY
--
++
++7776FU,T1
 END Position
 END Game_Summary
 EOF
@@ -264,14 +266,16 @@ END Time
 BEGIN Position
 P1-KY-KE-GI-KI-OU-KI-GI-KE-KY
 P2 * -HI *  *  *  *  * -KA * 
-P3-FU-FU-FU-FU-FU-FU * -FU-FU
-P4 *  *  *  *  *  * -FU *  * 
+P3-FU-FU-FU-FU-FU-FU-FU-FU-FU
+P4 *  *  *  *  *  *  *  *  * 
 P5 *  *  *  *  *  *  *  *  * 
-P6 *  * +FU *  *  *  *  *  * 
-P7+FU+FU * +FU+FU+FU+FU+FU+FU
+P6 *  *  *  *  *  *  *  *  * 
+P7+FU+FU+FU+FU+FU+FU+FU+FU+FU
 P8 * +KA *  *  *  *  * +HI * 
 P9+KY+KE+GI+KI+OU+KI+GI+KE+KY
 +
++7776FU,T1
+-3334FU,T1
 END Position
 END Game_Summary
 EOF
@@ -298,14 +302,16 @@ END Time
 BEGIN Position
 P1-KY-KE-GI-KI-OU-KI-GI-KE-KY
 P2 * -HI *  *  *  *  * -KA * 
-P3-FU-FU-FU-FU-FU-FU * -FU-FU
-P4 *  *  *  *  *  * -FU *  * 
+P3-FU-FU-FU-FU-FU-FU-FU-FU-FU
+P4 *  *  *  *  *  *  *  *  * 
 P5 *  *  *  *  *  *  *  *  * 
-P6 *  * +FU *  *  *  *  *  * 
-P7+FU+FU * +FU+FU+FU+FU+FU+FU
+P6 *  *  *  *  *  *  *  *  * 
+P7+FU+FU+FU+FU+FU+FU+FU+FU+FU
 P8 * +KA *  *  *  *  * +HI * 
 P9+KY+KE+GI+KI+OU+KI+GI+KE+KY
 +
++7776FU,T1
+-3334FU,T1
 END Position
 END Game_Summary
 EOF