/// <summary> /// Takes a playlist and scales it by the given width and height. /// </summary> public override void Run( ) { string bdir = "maps/scaled/" + Height + "x" + Width + "/"; Directory.CreateDirectory(bdir); StreamReader pl = new StreamReader(new FileStream( Playlist, FileMode.Open, FileAccess.Read)); string pll; while ((pll = pl.ReadLine( )) != null) { var ppls = pll.Split( ); StreamReader I = new StreamReader( new FileStream(ppls[0], FileMode.Open, FileAccess.Read)); GenericGridWorldStaticState SS; GenericGridWorldDynamicState DS; Loader.Load(I, out SS, out DS); SS.InitialDynamicState = DS; SS.Scale(Width, Height); int l = ppls[0].LastIndexOf("/"); string d = ppls[0].Substring(0, l); Directory.CreateDirectory(bdir + d); StreamWriter O = new StreamWriter( new FileStream(bdir + ppls[0], FileMode.Create, FileAccess.Write)); O.Write(GridWorldFormat.ToFileString(SS, DS)); O.Close( ); I.Close( ); } pl.Close( ); }
/// <summary> /// A constructor to setup all the applicable fields. /// </summary> /// <param name="IO"></param> /// <param name="WorldLoader"></param> /// <param name="Algorithm"></param> /// <param name="Weight"></param> public AlgorithmRunner(System.IO.TextReader IO, GridWorldLoader <GenericGridWorldStaticState, GenericGridWorldDynamicState> WorldLoader, String Algorithm, Metric Weight, bool Batch, StateVisualizer <GenericGridWorldStaticState, GenericGridWorldDynamicState> vis, int Seed) { gen = new Random(Seed); this.vis = vis; this.Goal = new DestinationsReachedGoal( ); this.Algorithm = new GenericAlgorithmFactory <GenericGridWorldStaticState, GenericGridWorldDynamicState>( ).SetRealTimeData( new SingleUnitOctileDistanceHeuristic( ), vis, new SingleUnitTransformer( ), Weight, 0.1).GetAlgorithm( Algorithm, null, 0); GenericGridWorldDynamicState InitialDynamicState; WorldLoader.Load(IO, out StaticState, out InitialDynamicState); IO.Close( ); this.Actions = GridWorldOperator.Ops; }
/// <summary> /// A constructor to setup all the applicable fields. /// </summary> /// <param name="IO"></param> /// <param name="WorldLoader"></param> /// <param name="Algorithm"></param> /// <param name="Weight"></param> public AlgorithmRunner( System.IO.TextReader IO, GridWorldLoader<GenericGridWorldStaticState, GenericGridWorldDynamicState> WorldLoader, String Algorithm, Metric Weight, bool Batch, StateVisualizer<GenericGridWorldStaticState, GenericGridWorldDynamicState> vis, int Seed) { gen = new Random( Seed ); this.vis = vis; this.Goal = new DestinationsReachedGoal( ); this.Algorithm = new GenericAlgorithmFactory<GenericGridWorldStaticState, GenericGridWorldDynamicState>( ).SetRealTimeData( new SingleUnitOctileDistanceHeuristic( ), vis, new SingleUnitTransformer( ), Weight, 0.1 ).GetAlgorithm( Algorithm, null, 0 ); GenericGridWorldDynamicState InitialDynamicState; WorldLoader.Load( IO, out StaticState, out InitialDynamicState ); IO.Close( ); this.Actions = GridWorldOperator.Ops; }