MingStar.SimUniversity.AI.GameState.TakeIfBetter C# (CSharp) Method

TakeIfBetter() private method

private TakeIfBetter ( GameState nextScoredMove, int scoreIndex, IPlayerMove thisMove ) : void
nextScoredMove GameState
scoreIndex int
thisMove IPlayerMove
return void
        internal void TakeIfBetter(GameState nextScoredMove, int scoreIndex, IPlayerMove thisMove)
        {
            double otherOffsetScore = nextScoredMove[scoreIndex] - Scores[scoreIndex];
            bool takeIt = false;
            if (Math.Abs(otherOffsetScore) < double.Epsilon)
            {
                if (nextScoredMove.Scores.Sum() < Scores.Sum())
                {
                    takeIt = true;
                }
            }
            else if (otherOffsetScore < 0.0)
            {
                return; // not take it
            }
            else if (otherOffsetScore > 0.0)
            {
                takeIt = true;
            }
            if (takeIt)
            {
                NextGameState = nextScoredMove;
                Scores = nextScoredMove.Scores;
                BestMove = thisMove;
            }
        }