public float CombinedDistance(CombinedPlatformAStar cpas, GameState state, GameObject next1, GameObject next2) { var combinedPath = cpas.CombinedPlatformPath (state.P1, state.P2, state.Goal, state.Goal); return Vector2.Distance (state.P1.SurfaceCenter, next1.Target) + Vector2.Distance (state.P2.SurfaceCenter, next2.Target) + WaypointHeuristic.PlatformPathDistance(combinedPath.Select(x => x.Item1), next1) + WaypointHeuristic.PlatformPathDistance(combinedPath.Select(x => x.Item2), next2); }
public void CombinedPlatformPath() { var level = Level.Level1; var cpas = new CombinedPlatformAStar (level.Platforms); var path = cpas.CombinedPlatformPath (level.P1, level.P2, level.Goal, level.Goal); string expected = "a, b, d, c, {X:105 Y:70}"; Assert.AreEqual (expected, PlatformUtil.PlatListStr(path.Select(x => x.Item1))); Assert.AreEqual (expected, PlatformUtil.PlatListStr(path.Select(x => x.Item2))); path = cpas.CombinedPlatformPath ( new Player(1, new Vector2(90, 36)), new Player(2, new Vector2(90, 45)), level.Goal, level.Goal); expected = "d|c, c|c, {X:105 Y:70}|{X:105 Y:70}"; Assert.AreEqual (expected, PlatformUtil.PlatPairListStr (path)); }
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 CombinedHeuristic(GameState state) { this.cpas = new CombinedPlatformAStar(state.Platforms); }