فهرست منبع

Removed boxing/unboxing of GameBoard

Vsevolod Levitan 4 ماه پیش
والد
کامیت
3c91fb876c
2فایلهای تغییر یافته به همراه3 افزوده شده و 3 حذف شده
  1. 2 2
      FourInARow/GameBoard.cs
  2. 1 1
      MinMaxABFourInARowBoard.cs

+ 2 - 2
FourInARow/GameBoard.cs

@@ -3,7 +3,7 @@ using MinMaxAB;
 
 namespace FourInARow;
 
-public class GameBoard : ICloneable
+public class GameBoard
 {
     public Player[][] cells;
     public readonly GameDimensions dimensions;
@@ -133,7 +133,7 @@ public class GameBoard : ICloneable
         return builder.ToString();
     }
 
-    public object Clone()
+    public GameBoard Clone()
     {
         var newBoard = new GameBoard(dimensions, cells.CopyArrayBuiltIn());
         return newBoard;

+ 1 - 1
MinMaxABFourInARowBoard.cs

@@ -116,7 +116,7 @@ public class MinMaxABFourInARowBoard
         List<(int Column, int Score)> moves = [];
         Parallel.For(0, board.dimensions.Columns, i =>
         {
-            var newBoard = (board.Clone() as GameBoard)!;
+            var newBoard = board.Clone();
             if (!newBoard.PlaceCoin(Player.Computer, i)) return;
             moves.Add((i, EvaluateMinMax(newBoard, depth)));
         });