I'm planning to train a bot in the rocket league hoops mode, it's the same as standard…
- User
I'm planning to train a bot in the rocket league hoops mode, it's the same as standard mode except the ball radius is slightly larger, the arena is smaller and the goals are baskets with a hole shaped like half pills surrounded by a rim and slope. . The issue is that my goal related rewards no longer work in hoops because of the different goal designs. In regular mode the goal is just a hole in a wall, but now in hoops it's a basket. So I can't just target a x,y coordinate, I now need to target a x,y,z target from above. Since the ball needs to fall in to the net it makes things a lot more complicated. The sides of the basket are solid, so I can't just aim for the x,y,z coordinate because there might be a basketwall in the way. I somehow need to encourage the ball to parabola from bellow the goal and go straight when above the goal height, I think that makes sense. This is my current ball to goal reward for standard mode: class BallTowardsGoalReward : public RewardFunction { public: BallTowardsGoalReward(bool ownGoal = false, float angleThreshold = 0.6f) : ownGoal(ownGoal), angleThreshold(angleThreshold) {}
codevirtual void Reset(const GameState& initial_state) override { // No reset behavior needed } virtual float GetReward(const PlayerData& player, const GameState& state, const Action& prevAction) override { bool targetOrangeGoal = player.team == Team::BLUE; if (ownGoal) targetOrangeGoal = !targetOrangeGoal; // Define goal dimensions const float GOAL_WIDTH = 892.755f; const float GOAL_HEIGHT = 642.775f; float goalY = CommonValues::BACK_WALL_Y * (targetOrangeGoal ? 1 : -1); float distToScoring = std::abs(state.ball.pos.y - goalY); float timeToScoring = distToScoring / (std::abs(state.ball.vel.y) + 1e-6f); Vec gravityDrop = Vec(0, 0, CommonValues::GRAVITY_Z) * std::pow(timeToScoring, 2) * 0.5f; Vec extrapBallPos = state.ball.pos + state.ball.vel * timeToScoring + gravityDrop; extrapBallPos.z = std::max(extrapBallPos.z, CommonValues::BALL_RADIUS); Vec targetPos = { std::clamp(extrapBallPos.x, -GOAL_WIDTH, GOAL_WIDTH), goalY, std::clamp(extrapBallPos.z, 0.0f, GOAL_HEIGHT) }; // Calculate direction vectors Vec ballDirToGoal = (targetPos - state.ball.pos).Normalized(); Vec ballHeadingDir = state.ball.vel.Normalized(); // Calculate dot product float unAlign = ballDirToGoal.Dist(ballHeadingDir); float reward = 1.0f - (unAlign / angleThreshold); reward = std::max(reward, 0.0f) * state.ball.vel.Length() / CommonValues::BALL_MAX_SPEED; return reward; } - Assistant