protected void Initialize(GameState level) { state = level; // state = level.Clone(p1: new Player (1, new Vector2 (90, 36)), // p2: new Player (2, new Vector2 (90, 45))); forwardModel = new ForwardModel (state); history = new List<GameState> (); // ai1 = new NullAI (state, PlayerId.P1); ai1 = new AStar (state, PlayerId.P1, new WaypointHeuristic (state, PlayerId.P1)); ai2 = new AStar (state, PlayerId.P2, new WaypointHeuristic (state, PlayerId.P2)); // listInputMethod = new ListAiInput (ai1, ai2, state); // inputMethod = new SynchronizedAiInput (ai1, ai2, state); // inputMethod = new HalfHumanAiInput (ai2, state); combinedInputMethod = new CombinedAiInput (state); humanInputMethod = new HumanInput (state, combinedInputMethod); // inputMethod = humanInputMethod; inputMethod = combinedInputMethod; CombinedPlatformAStar cpas = new CombinedPlatformAStar (level.Platforms); cpas.CombinedPlatformPath (level.P1, level.P2, level.Goal, level.Goal); // Environment.Exit (1); }
public void DrawMethodVisualizations(GameState state, CombinedAiInput cim) { Vector2 p1offset = new Vector2 (0, 5); DrawScore (PlayerId.P1, cim.Heuristic.Score(state), 20, 50); DrawPlatformSubdivisions (state.Platforms); var combinedPath = cim.Heuristic.Path (state); // Draw platform targets for (int i = 0; i < combinedPath.Count; i++) { var val = i / (float)combinedPath.Count; Color c = Drawing.HeatmapColor (val); DrawCircle(2, combinedPath [i].Item1.Target + p1offset, c); DrawCircle(2, combinedPath [i].Item2.Target, c); } // Draw platform paths var platformPaths = cim.Heuristic.cpas.CombinedPlatformPath ( state.P1, state.P2, state.Goal, state.Goal); var nPlats = (float)platformPaths.Count; DrawPath (platformPaths.Select ((tup, i) => Tuple.Create(HeatmapColor(i / nPlats), tup.Item1.Target + new Vector2(0, p1offset.Y))), 2); DrawPath (platformPaths.Select ((tup, i) => Tuple.Create(HeatmapColor(i / nPlats), tup.Item2.Target)), 2); // Draw target platforms var nextPlats = cim.Heuristic.cpas.NextPlatform(state.P1, state.P2, state.Goal, state.Goal); DrawCircle(1, nextPlats.Item1.Target + p1offset, Color.BlanchedAlmond); DrawCircle(1, nextPlats.Item2.Target, Color.BlanchedAlmond); // Draw heatmapped hypothetical player paths DrawPaths (cim.Ai.AllPaths().AsEnumerable().Reverse().Take(2).Select(t => Tuple.Create(t.Item1, t.Item2.Select(e => e.Item2.P1.SurfaceCenter)))); foreach (var path in cim.Ai.AllPaths().Take(1)) { var score = path.Item1; var coords1 = path.Item2.Last ().Item2.P1.SurfaceCenter; var coords2 = path.Item2.Last ().Item2.P1.SurfaceCenter; // Debug.Print ("nextPath1: {0}", CombinedAi.moveListStr(path.Item2.Select(x => x.Item1.Item1))); // Debug.Print ("nextPath2: {0}", CombinedAi.moveListStr(path.Item2.Select(x => x.Item1.Item2))); } DrawPaths (cim.Ai.AllPaths().AsEnumerable().Reverse().Take(2).Select(t => Tuple.Create(t.Item1, t.Item2.Select(e => e.Item2.P2.SurfaceCenter)))); }