OSDN Git Service

Back to Marshal for deep copy.
authorbeatles <beatles@b8c68f68-1e22-0410-b08e-880e1f8202b4>
Wed, 8 Oct 2008 13:38:18 +0000 (13:38 +0000)
committerbeatles <beatles@b8c68f68-1e22-0410-b08e-880e1f8202b4>
Wed, 8 Oct 2008 13:38:18 +0000 (13:38 +0000)
  * previous implementatoin was wrong.
  * No longer need to avoid Marshal since only the files related with Floodgate
    are reloaded.

shogi_server/board.rb

index efc1e36..379dc69 100644 (file)
@@ -34,20 +34,7 @@ class Board
   attr_reader :move_count
 
   def deep_copy
   attr_reader :move_count
 
   def deep_copy
-    # return Marshal.load(Marshal.dump(self))
-    board = Board.new(self.move_count)
-    board.sente_hands   = self.sente_hands.clone
-    board.gote_hands    = self.gote_hands.clone
-    board.history       = self.history.clone
-    board.history.default = 0
-    board.sente_history = self.sente_history.clone
-    board.sente_history.default = 0
-    board.gote_history  = self.gote_history.clone
-    board.gote_history.default = 0
-    board.array = []
-    self.array.each {|a| board.array.push(a.clone)}
-    board.teban         = self.teban
-    return board
+    return Marshal.load(Marshal.dump(self))
   end
 
   def initial
   end
 
   def initial