Example #1
0
        /// <summary>
        /// Solves the algorithm.
        /// </summary>
        /// <param name="Out"></param>
        /// <returns></returns>
        public Solution Solve(TextWriter Out)
        {
            var alg = new Net.Mokon.Edu.Unh.CS.AI.Search.Algorithms.AStar <
                GenericGridWorldStaticState, GenericGridWorldDynamicState>(
                new SingleUnitOctileDistanceHeuristic( ), true, null);
            var sol = alg.Compute(
                StaticState, StaticState.InitialDynamicState, Goal, this.Actions);

            if (Out != null)
            {
                lock ( Out ) {
                    Out.WriteLine(
                        "AStar, N/A, " + alg.Expansions +
                        ", " + alg.Generations + ", N/A, " + sol.First( ).Cost);
                    Out.Flush( );
                }
            }
            return(new Solution(sol.First( ), alg));
        }
Example #2
0
 /// <summary>
 /// Solves the algorithm.
 /// </summary>
 /// <param name="Out"></param>
 /// <returns></returns>
 public Solution Solve( TextWriter Out )
 {
     var alg = new Net.Mokon.Edu.Unh.CS.AI.Search.Algorithms.AStar<
     GenericGridWorldStaticState, GenericGridWorldDynamicState>(
       new SingleUnitOctileDistanceHeuristic( ), true, null );
       var sol =  alg.Compute(
     StaticState, StaticState.InitialDynamicState, Goal, this.Actions );
       if ( Out != null ) {
     lock ( Out ) {
       Out.WriteLine(
       "AStar, N/A, " + alg.Expansions +
         ", " + alg.Generations + ", N/A, " + sol.First( ).Cost );
       Out.Flush( );
     }
       }
       return new Solution( sol.First( ), alg );
 }