Exemple #1
0
        public int evaluate(Case eval, long[] highs, long[] lows)
        {
            // to guess we first make a tower for the eval case
            long tower = build_tower(eval);

            // make a short list of possible values
            List<int> shortlist = new List<int>();
            for (int n = 0; n < 10; n++)
            {
                if (tower >= lows[n] && tower <= highs[n]) shortlist.Add(n);
            }

            // guess
            if (shortlist.Count == 0)
            {
                Console.WriteLine("Got 0 possibilities, guessing 4, its always 4");
                return 4;
            }
            else if(shortlist.Count == 1)
            {
                Console.WriteLine("Making a good guess");
                return shortlist[0];
            }
            else
            {
                Console.WriteLine("Got " + shortlist.Count + " possibilities, making random choice");
                return shortlist[r.Next(0, shortlist.Count)];
            }
        }
Exemple #2
0
        public long build_tower(Case eval)
        {
            long tower = 0;
            int e = 0;

            //features
            if (use_features)
            {
                int f = 0;
                for (int dir = 0; dir < 4; dir++) //for all four directions
                {
                    for (int entry = 0; entry < 28; entry++) //for all 28 entries in this direction
                    {
                        for (int val = 0; val < 28; val++)          //for all 28 possible values for this entry
                        {
                            if (expression[e] != 0) if (eval.features[f] >= val) tower += expression[e];
                            e++;
                            if (expression[e] != 0) if (eval.features[f] < val) tower+= expression[e];
                            e++;
                        }
                        f++;
                    }
                }
            }

            //volumes
            int v = 0;
            if (use_volumes)
            {
                for (int dir = 0; dir < 2; dir++) //for all two directions
                {
                    for (int entry = 0; entry < 28; entry++) // for all 28 entries in this direction
                    {
                        for (int val = 0; val < 28; val++)           //for all 28 possible values for this entry
                        {
                            if (expression[e] != 0) if (eval.volumes[v] >= val) tower += expression[e];
                            e++;
                            if (expression[e] != 0) if (eval.volumes[v] < val) tower += expression[e];
                            e++;
                        }
                        v++;
                    }
                }
            }

            return tower;
        }