// ported from python, no idea what it does public static void LinearCombinationPlayer(GameLogic.IView v, GameLogic.IGenome g, Random rnd, out int ox, out int oy) { ox = 0; oy = 0; var restrictedCoords = lcpcoords.Where(c => v[c.x, c.y] > -1).ToArray(); var rcCount = restrictedCoords.Length; int s = 0; for (int i = 0; i < 25; i++) s += (int)g.cutOutInt(2 * i, 2) * v[i / 5 - 2, i % 5 - 2]; Coord res = restrictedCoords[(s + rcCount * 1000/*bignumber*/) % rcCount]; ox = res.x; oy = res.y; }
public static void FearPlayerMk2(GameLogic.IView v, GameLogic.IGenome g, Random rnd, out int ox, out int oy) { int fearCount = 8; int fearSize = 2; int[] fear = new int[fearCount]; for (int i = 0; i < fearCount; i++) { fear[i] = 0; for (int j = 0; j < fearSize; j++) fear[i] ^= (int)g.cutOutInt(i * fearSize * 4 + j * 4, 4); } if (v[-1, 0] != -1 && Array.IndexOf(fear, v[0, 0]) >= 0) goto no; Coord[] nofear = fwcoords.Where(c => Array.IndexOf(fear, v[c.x, c.y]) < 0).ToArray(); if (nofear.Length == 0) goto no; Coord fc = fwcoords[rnd.Next(fwcoords.Length)]; ox = fc.x; oy = fc.y; return; no: // ox = 0; // oy = 0; // return; if (v[-1,-1] == -1) { ox = -1; oy = -1; return; } if (v[-1,1] == -1) { ox = -1; oy = -1; return; } Coord bc = bwcoords[rnd.Next(bwcoords.Length)]; ox = bc.x; oy = bc.y; return; }
public static void fgrr(GameLogic.IView v, GameLogic.IGenome g, Random rnd, out int ox, out int oy) { // defaults ox = 1; // into the unknown oy = 0; int k = 2; for (int j = 0; j < 3; j++) { foreach (Coord c in fgrrcoords.Where(c => c.x > 0)) { for (int i = j * k; i < j * k + k; i++) { uint ci = g.cutOutInt(i * 4, 4); if (v[c.x, c.y] == ci) { ox = c.x; oy = c.y; return; } } } } for (int j = 0; j < 3; j++) { foreach (Coord c in fgrrcoords.Where(c => c.x == 0)) { for (int i = j * k; i < j * k + k; i++) { uint ci = g.cutOutInt(i * 4, 4); if (v[c.x, c.y] == ci) { ox = c.x; oy = c.y; return; } } } } }
// this implementation isn't inefficient atall public static void ColorScorePlayer(GameLogic.IView v, GameLogic.IGenome g, Random rnd, out int ox, out int oy) { ox = 0; oy = 0; var max_score = cspcoords.Where(c => v[c.x, c.y] > -1).Select(c => g.cutOutInt(6 * v[c.x, c.y], 6)).Max(); var restrictedCoords = cspcoords.Where(c => v[c.x, c.y] > -1 && g.cutOutInt(6 * v[c.x, c.y], 6) == max_score).ToArray(); Coord res = restrictedCoords[rnd.Next(restrictedCoords.Length)]; ox = res.x; oy = res.y; }