public static float EstimateScore(PlayerId pId, GameState state, Input move, Vector2 target) { // prof.Start (); float similarity; if (move == Input.Noop) { similarity = 0f; } else { var player = state.Player (pId); Vector2 gravOffset = state.IsGrounded (player) ? Vector2.Zero : gravVector; Vector2 targetVector = Vector2.Subtract (target, player.Target + gravOffset); Vector2.Normalize (targetVector); // Debug.WriteLine("targetVector: {0}", gravOffset); similarity = (float)Util.CosineSimilarity(targetVector, moveVectors [move]); } // prof.End (); return -similarity; }
public float statusWrap(GameState state, float s) { float healthScore = System.Math.Abs(state.Health); var healthWeight = 150f; var score = s + (healthWeight * healthScore); if (state.PlayStatus.isDied () || state.Player(pId).BottomBoundary < state.Platforms.Min(x => x.TopBoundary)) { score = 5*GameState.Width; } else if (state.PlayStatus.isWon ()) { score = 0; } return score; }
private float PlatformPathDistance(GameState state, PlayerId pId, GameObject platform) { return PlatformPathDistance (pas.PlatformPath (state.Player (pId), state.Goal), platform); }
public GameObject NextPlatform(GameState state) { return pas.NextPlatform (state.Player(pId), state.Goal); }
public static float PlayerDistance(PlatformAStar pas, GameState state, PlayerId pId, GameObject target) { return Vector2.Distance (state.Player(pId).SurfaceCenter, target.Target) + PlatformPathDistance (pas.PlatformPath (state.Player (pId), state.Goal), target); }
public override float Score(GameState state) { float goalDistance = Vector2.Distance(state.Player(pId).Coords, state.Goal.Coords); float healthScore = System.Math.Abs(state.Health); var healthWeight = 0f; return goalDistance + (healthWeight * healthScore); }
public static Player otherPlayer(this AI ai, GameState state) { return state.Player (ai.pId == PlayerId.P1 ? PlayerId.P2 : PlayerId.P1); }
public static Player thisPlayer(this AI ai, GameState state) { return state.Player (ai.pId); }