Results 1 to 5 of 5
  1. #1
    pianodave1984's Avatar
    pianodave1984 is offline Aspiring Javaman
    Join Date
    Sep 2013
    Location
    West Chester PA
    Posts
    8
    Rep Power
    0

    Default Baseball Simulator Program

    Hey guys! First time post. I have a question:

    First, I'm "semi" new to Java. I've written a number of programs, mainly simple ones to get totally comfortable with console before I move more into what I'm in with JFrame and GUI stuff.

    I want to just have the console print out the outcome of atbats, but I want to use, say if Ryan Howard was at the plate and Cliff Lee was pitching. I want weighted randomness, I guess is what I'm asking.

    Is there a way to add weight to the Math.random() function so that Ryan Howard doesn't hit .400 with 2 homeruns?

    Thanks guys!

  2. #2
    jim829 is online now Senior Member
    Join Date
    Jan 2013
    Location
    United States
    Posts
    2,936
    Rep Power
    4

    Default Re: Baseball Simulator Program

    But two times at bat with two home runs is .400. However, you could make it more meaningful by working in the number of times at bat.

    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  3. #3
    pianodave1984's Avatar
    pianodave1984 is offline Aspiring Javaman
    Join Date
    Sep 2013
    Location
    West Chester PA
    Posts
    8
    Rep Power
    0

    Default Re: Baseball Simulator Program

    Quote Originally Posted by jim829 View Post
    But two times at bat with two home runs is .400. However, you could make it more meaningful by working in the number of times at bat.

    Regards,
    Jim
    I think my main question is, how do the baseball simulators like OOTP work? I was trying to program just a simple one to get a more sophisticated win-loss record. But I can't see how they're programmed, or what kind of math they're using.

    Is there a way to get a random number that will be influenced by a player's overall and past/recent performance?

  4. #4
    jim829 is online now Senior Member
    Join Date
    Jan 2013
    Location
    United States
    Posts
    2,936
    Rep Power
    4

    Default Re: Baseball Simulator Program

    I don't know about OOTP. If you want to calculate what a hitters average is it is essentially number of hits divided by number of times at bat. If you have a fictitious batter in a game and you want to see if the batter gets a hit or not. Then just generate a number between 0 and 1. If the number is less than or equal to the batter's average, he gets a hit. If greater than he doesn't. You could also work in home run stats and rbi stats too.

    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  5. #5
    pianodave1984's Avatar
    pianodave1984 is offline Aspiring Javaman
    Join Date
    Sep 2013
    Location
    West Chester PA
    Posts
    8
    Rep Power
    0

    Default Re: Baseball Simulator Program

    Quote Originally Posted by jim829 View Post
    I don't know about OOTP. If you want to calculate what a hitters average is it is essentially number of hits divided by number of times at bat. If you have a fictitious batter in a game and you want to see if the batter gets a hit or not. Then just generate a number between 0 and 1. If the number is less than or equal to the batter's average, he gets a hit. If greater than he doesn't. You could also work in home run stats and rbi stats too.

    Regards,
    Jim
    I already know how to calculate the statistics but you helped me out TONS with the last part. That's working beautifully! Thanks a bunch

Similar Threads

  1. simulator program with RS232
    By john wooo in forum Networking
    Replies: 7
    Last Post: 02-11-2009, 02:26 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •