private double CalculateCollectibleDistanceValue(IntraPlatformPlayedGameStateInfo state) { double agentXPosition = state.State.xPos; double agentYPosition = state.State.yPos; Collectible c = state.State.GetClosestCollectible(); switch (state.Move) { case Moves.ROLL_LEFT: agentXPosition -= 2 * CircleWorldModel.DEFAULT_RADIUS; break; case Moves.ROLL_RIGHT: agentXPosition += 2 * CircleWorldModel.DEFAULT_RADIUS; break; case Moves.JUMP: agentYPosition -= 2 * CircleWorldModel.DEFAULT_RADIUS; break; default: break; } return(10000 * 1 / Utils.Utils.CalculateL2(agentXPosition, agentYPosition, c.xPos, c.yPos)); }
private void UpdateLearning(IntraPlatformPlayedGameStateInfo state) { Platform p = _model.GetPlatform(state.PlatformId); double stateValue = p.NumberCollectiblesCaught * 1000; stateValue += state.State.GetNumberCollectiblesCaught() * 1000; stateValue += CalculateCollectibleDistanceValue(state); stateValue += ((_model.TimeLimit / _model.TimeElapsed) - 1) * 1000; if (stateValue > 0) { if (_intraplatformLessonsLearnt.ContainsKey(state.State.GetStateId())) { if (_intraplatformLessonsLearnt[state.State.GetStateId()].ContainsKey(state.Move)) { _intraplatformLessonsLearnt[state.State.GetStateId()][state.Move] = 0.99 * _intraplatformLessonsLearnt[state.State.GetStateId()][state.Move] + 0.01 * stateValue; } else { _intraplatformLessonsLearnt[state.State.GetStateId()].Add(state.Move, stateValue); } } else { _intraplatformLessonsLearnt.Add(state.State.GetStateId(), new Dictionary <Moves, double>()); _intraplatformLessonsLearnt[state.State.GetStateId()].Add(state.Move, stateValue); } } }