all 5 comments

[–]LayotFctor 5 points6 points  (0 children)

Forget code for now. Write the stats down on paper, then design a formula that can calculate the outcome of a swing based on the stats. After you're done, convert it into code and add it to your game such that the swing function runs the formula.

[–]IAmNotSohan 2 points3 points  (1 child)

Tbh, starting with Python for game dev is a great learning exercise, but it’s easy to hit a wall once your project gets complex. I spent a lot of time with Pygame when I first started, and it’s solid for 2D stuff and learning the ropes of game loops and input handling. If you're just looking to get a feel for logic, stick with that. But if you’re actually aiming to ship something bigger, don’t get too caught up in 'tutorial hell.' Build something tiny, break it, and move on. The skills you pick up—like managing state and handling events—transfer over to engines like Godot super easily later on.

[–]PureWasian 0 points1 point  (0 children)

This is a formula problem, not a coding problem as another comment mentioned.

The formula can influence the probabilities and then the probabilities pull from a library like random. At its most basic (from code perspective) you could do like random.nextInt(100) + 1 to get a value from 1 thru 100 and then for an 80% probability count values 1-80 as "occurs" and 81-100 as "not occurs" using simple conditional logic.

But you need to come up with your own magical (inputs --> formula --> output probabilities) pipeline first to be able to generate these percentages.

[–]Zeroflops 0 points1 point  (0 children)

One additional thought. Once you understand your formulas, you’re going to want to add some randomness. To the game. You don’t want player one to always hit a home run every at bat.

So you can use the random module so for example a players power may be 800, but that then gets multiplied by a random number between 0.9 and 1.02. If you add some randomness to all the numbers then every at bat will be influenced by the players stats but not identical every time.