private static string WhiteTurn(string board) { var engine = new WhiteCheckersEngine(board); var positions = engine.GetPossiblePositions(); var rnd = new Random(); return(positions.Count > 0 ? positions[rnd.Next(0, positions.Count - 1)].Last() : null); }
private int WhiteMax(string board, int currentDepth, int alpha) { var engine = new WhiteCheckersEngine(board); var positions = engine.GetPossiblePositions(); if (positions == null || positions.Count == 0) { return(0); } var maxPos = int.MinValue; foreach (var position in positions) { var posWeight = 0; for (var i = 0; i < position[position.Count - 1].Length; i++) { if (position[position.Count - 1][i] == 'b') { posWeight -= BlackWeights[i]; } if (position[position.Count - 1][i] == 'B') { posWeight -= KingWeights[i]; } if (position[position.Count - 1][i] == 'w') { posWeight += WhiteWeights[i]; } if (position[position.Count - 1][i] == 'W') { posWeight += KingWeights[i]; } } if (currentDepth < Depth) { posWeight -= BlackMax(position[position.Count - 1], currentDepth + 1, maxPos); } if (posWeight > maxPos) { maxPos = posWeight; } if (maxPos >= alpha) { return(maxPos); } } return(maxPos); }
private static Engine WhiteTurn(string board) { var engine = new WhiteCheckersEngine(board); return(engine); }