private static string BlackTurn(string board = null) { var engine = new BlackCheckersEngine(board); var positions = engine.GetPossiblePositions(); var rnd = new Random(); return(positions.Count > 0 ? positions[rnd.Next(0, positions.Count - 1)].Last() : null); }
private int BlackMax(string board, int currentDepth, int beta) { var engine = new BlackCheckersEngine(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]; } } posWeight -= WhiteMax(position[position.Count - 1], currentDepth, maxPos); if (posWeight > maxPos) { maxPos = posWeight; } if (maxPos < beta) { return(maxPos); } } return(maxPos); }
private static Engine BlackTurn(string board) { var engine = new BlackCheckersEngine(board); return(engine); }