Browse Source

Fixed concurrency

Vsevolod Levitan 4 months ago
parent
commit
15a42b20d8
1 changed files with 2 additions and 1 deletions
  1. 2 1
      Connect4Minimax.cs

+ 2 - 1
Connect4Minimax.cs

@@ -1,3 +1,4 @@
+using System.Collections.Concurrent;
 using Connect4;
 
 namespace MinMaxAB;
@@ -154,7 +155,7 @@ public class Connect4Minimax
 
     public static int GetBestMove(GameBoard board, int depth)
     {
-        List<(int Column, int Score)> moves = [];
+        ConcurrentBag<(int Column, int Score)> moves = [];
         // Parallel.For(0, board.dimensions.Columns, new() { MaxDegreeOfParallelism = 1 }, i =>
         Parallel.For(0, board.dimensions.Columns, i =>
         {