コード例 #1
0
        public static void LemmingPlayer(GameLogic.IView v, GameLogic.IGenome g, Random rnd, out int ox, out int oy)
        {
            Coord res = lpcoords[rnd.Next(lpcoords.Length)];

            ox = res.x;
            oy = res.y;
        }
コード例 #2
0
        public static void StatsPlayer(GameLogic.IView v, GameLogic.IGenome g, Random rnd, out int ox, out int oy)
        {
            ox = 0;
            oy = 0;

            int[] s = new int[16];
            for (int i = -v.xd; i <= v.xd; i++)
            {
                for (int j = -v.yd; j <= v.yd; j++)
                {
                    int h = v[i, j];
                    if (h >= 0)
                    {
                        s[h]++;
                    }
                }
            }

            int b = 0, c = 0, d = 0;

            for (int i = 0; i < s.Length; i++)
            {
                if (s[i] > s[b])
                {
                    d = c;
                    c = b;
                    b = i;
                }
            }

            Coord[] okcs;

            okcs = fwcoords.Where(crd => v[crd.x, crd.y] == b).ToArray();
            if (okcs.Length != 0)
            {
                Coord k = okcs[rnd.Next(okcs.Length)];
                ox = k.x;
                oy = k.y;
                return;
            }

            okcs = fwcoords.Where(crd => v[crd.x, crd.y] == c).ToArray();
            if (okcs.Length != 0)
            {
                Coord k = okcs[rnd.Next(okcs.Length)];
                ox = k.x;
                oy = k.y;
                return;
            }

            okcs = fwcoords.Where(crd => v[crd.x, crd.y] == d).ToArray();
            if (okcs.Length != 0)
            {
                Coord k = okcs[rnd.Next(okcs.Length)];
                ox = k.x;
                oy = k.y;
                return;
            }
        }
コード例 #3
0
        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;
        }
コード例 #4
0
        // 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;
        }
コード例 #5
0
        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;
                        }
                    }
                }
            }
        }
コード例 #6
0
        // 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;
        }