Skip to main content
GameDev.net gamedev.net
🔒 Locked

baseball game

Started by cwl157 Sep 30, 2008 at 9:49 AM 0 replies 700+ views
Original Post
cwl157
cwl157
I am making a baseball game where the players have attributes and these attributes act as modifiers on simulated dice rolls to determine the result of each pitch between the pitcher and batter. I am in the process of making the if, else if, else tree for the player decisions. I am taking into account their own attributes along with the attributes of the player on deck, and the number of outs in an inning. These factors would determine how likely a player is to swing or sacrifice, or bunt in that given situation. I was thinking of making seperate methods for each swing, sacrifice, bunt that would return true if thats what the player decides to do. I am having a bit of trouble figuring out how to accommodate all of the possibilities. Anyone have any suggestions? Thanks
cwl157
cwl157
I think what i need is just a bunch of if else if statements.

The first level would be how many outs there are, 0, 1, 2. Then it would go to how many are on base and where they are, then it would go into looking at the actual player stats to determine the percentage that it should happen. So it would look like this:


if (outs == 2)
{
if (first and 2nd base full)
{
if (compare player stats)
swing 60% of the time.
}
}


So maybe have a method that just takes an int percentage and will return true that many percent of times. Is that possible? Then i can just make all these if statements, making sure to include every possibility and then have if statements inside those that determine what percentage of the time something happens. In each section like exampled above the percentages would have to equal 100% because for each situation something has to happen.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.