コード例 #1
0
ファイル: RivalsEval.cs プロジェクト: limonana/AI_Course
        private int GetDistanceFromGoal(TravelWorld world, int currentLoc, int goal, out bool realDistance)
        {
            if (currentLoc == goal)
            {
                realDistance = true;
                return(0);
            }

            var path = world.findCheapestCleartPath(currentLoc, goal);

            if (path != null)
            {
                realDistance = true;
                return(path.Count);
            }
            else
            {
                realDistance = false;
                path         = world.findCheapestPath(currentLoc, goal);
                if (path == null)
                {
                    return(int.MaxValue);
                }
                else
                {
                    return(path.Count);
                }
            }
        }
コード例 #2
0
ファイル: NaturalEval.cs プロジェクト: limonana/AI_Course
        public double Run(TravelGameState state)
        {
            if (state.locations[_player] == _goal)
            {
                return(0);
            }
            TravelWorld world           = state.ToWorld();
            TravelPath  cheapPath       = world.findCheapestPath(state.locations[_player], _goal);
            var         closeToPenality = (_MaxMoves - state.totalMoves[_player]) - cheapPath.Count;
            var         res             = -cheapPath.Cost();

            if (closeToPenality <= 0)
            {
                res += 100;
            }
            return(res);
        }