Exemple #1
0
        static public CompareZone Zone(Move moveOrNull)
        {
            if (moveOrNull == null)
            {
                return(CompareZone.Null);
            }

            CompareZone compareZone = (CompareZone)2 - Math.Sign(moveOrNull.LengthIncrease);

            return(compareZone);
        }
Exemple #2
0
        private void MakeCheck(Move bestMove)
        {
            //Debug.WriteLine(string.Format("\tVaccine\t{0}", VaccineAsString.String));

            double rSelfScore = SelfScore();
            double rRealScore = RealScore();

            CompareZone zone = Move.Zone(bestMove);

            Debug.Assert(rSelfScore <= rRealScore + 1e-10);
            if (zone == CompareZone.LengthIncreases)
            {
                double rMissing = rRealScore - rSelfScore;
                if (rMissing > 1e-10)
                {
                    Debug.WriteLine(string.Format("It looks like {0} free points are being missed. It may not be a problem if false edge unification is the cause", rMissing));
                }
            }

            double rTotalPoints = rSelfScore + UnusedScore();

            Debug.Assert(double.IsNaN(PointsInPatchTable) || Math.Abs(rTotalPoints - PointsInPatchTable) < 1e-10);
        }
Exemple #3
0
        public static Move MaxOrNull(Move moveOrNull, Move bestMoveOrNull)
        {
            CompareZone zone     = Zone(moveOrNull);
            CompareZone bestZone = Zone(bestMoveOrNull);

            if (zone > bestZone)
            {
                return(moveOrNull);
            }

            if (bestZone > zone)
            {
                return(bestMoveOrNull);
            }

            Debug.Assert(bestZone == zone);

            switch (zone)
            {
            case CompareZone.Null:
                return(null);

            case CompareZone.LengthIncreases:
            {
                double scorePerLength     = moveOrNull.ScoreImprovement / (double)moveOrNull.LengthIncrease;
                double scorePerLengthBest = bestMoveOrNull.ScoreImprovement / (double)bestMoveOrNull.LengthIncrease;
                if (scorePerLength > scorePerLengthBest)
                {
                    return(moveOrNull);
                }
                else
                {
                    return(bestMoveOrNull);
                }
            }

            case CompareZone.LengthUnchanged:
            {
                if (moveOrNull.ScoreImprovement > bestMoveOrNull.ScoreImprovement)
                {
                    return(moveOrNull);
                }
                else
                {
                    return(bestMoveOrNull);
                }
            }

            case CompareZone.LengthDecreases:
            {
                Debug.Assert(moveOrNull.ScoreImprovement == 0 && bestMoveOrNull.ScoreImprovement == 0);                         // real assert
                if (moveOrNull.LengthIncrease < bestMoveOrNull.LengthIncrease)
                {
                    return(moveOrNull);
                }
                else
                {
                    return(bestMoveOrNull);
                }
            }

            default:
            {
                SpecialFunctions.CheckCondition(false, "Unknown zone (shouldn't get here");
                return(null);
            }
            }
        }