OSDN Git Service

Merge branch '201410-maxmoves'
[shogi-server/shogi-server.git] / shogi_server / board.rb
index 66d4d01..bcf8887 100644 (file)
@@ -626,6 +626,7 @@ EOF
   #   - :uchifuzume 
   #   - :oute_kaihimore 
   #   - (:outori will not be returned)
+  #   - :max_moves
   #
   def handle_one_move(str, sente=nil)
     if (str =~ /^([\+\-])(\d)(\d)(\d)(\d)([A-Z]{2})/)
@@ -713,6 +714,14 @@ EOF
       return :sennichite 
     end
 
+    # New rule that CSA introduced in November 2014.
+    # If a game with 256 plies does not end, make the game a draw.
+    # When running test cases $options might be nil.
+    if $options && $options["max-moves"] &&
+       $options["max-moves"] > 0 && @move_count >= $options["max-moves"]
+      return :max_moves
+    end
+
     return :normal
   end