public static void Mute(AI.DNA dna, ICollection <string> keys, int rate, float min, float max) { string[] banned = new string[] { "f5", "name", "generation" }; foreach (string key in keys) { if (!string.IsNullOrEmpty(key)) { bool ok = true; for (int i = 0; i < banned.Length; i++) { if (banned[i] == key) { ok = false; break; } } if (ok) { dna.SetValue(key, (float)Utility.RandomValue(dna.GetValue(key), rate, min, max)); } } } }
public float ScanLine(int x, int y, 棋子 side, 棋子[][] positions, int deltaX, int deltaY, List <KeyValuePair <int, int> > list) { float val = 0f; int xLength = positions[0].Length; int yLength = positions.Length; int startX = -1; int startY = -1; int endX = -1; int endY = -1; StringBuilder builder = new StringBuilder(); while (true) { bool isIn = IsInChess(x, y); if (isIn && side == positions[x][y]) { if (startX < 0) { startX = x; startY = y; } endX = x; endY = y; } else { if (startX >= 0) { int num = Math.Max(Math.Abs(endX - startX + 1), Math.Abs(endY - startY + 1)); if (num > 5) { num = 5; } int space = 5 - num; builder.Clear(); FindCode(num, space, -1, startX, startY, xLength, yLength, deltaX, deltaY, side, positions, builder, list); builder.Append(num.ToString()); FindCode(num, space, 1, endX, endY, xLength, yLength, deltaX, deltaY, side, positions, builder, list); Fix(ref builder); string code = builder.ToString(); int length = CalculateLength(code, num); if (length >= 5) { if (code == "5") { code = "f5"; } val += _dna.GetValue(code); } startX = -1; startY = -1; endX = -1; endY = -1; } if (!isIn) { break; } } x += deltaX; y += deltaY; } return(val); }