Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Java Old Dos program (Wa-tor) ported to Java runs too quickly

  1. Jun 20, 2014 #1
    When I was a (very lonely) child, I used to play endlessly with this predator-prey simulation game:

    (You may have trouble getting this applet to run based on java updates, other security settings and what not).

    There is more information about it here:


    This program would actually be a great compliment to a presentation I'm thinking of doing. (Haven't found one on the web that works as well).

    However, the thing runs EXTREMELY fast. It was originally meant to run on a 1985 DOS machine.

    I don't know anything about Java. Is there any easy way to slow it down?

    -Dave K
  2. jcsd
  3. Jun 20, 2014 #2


    User Avatar
    Gold Member

    How do I play it?
  4. Jun 20, 2014 #3


    User Avatar
    Homework Helper

    Assuming there's a main loop in the game, add an inner loop that just iterates, perhaps with some type of sleep like function.
  5. Jun 20, 2014 #4


    User Avatar
    Gold Member

    Use a timer with a callback function to the game logic.
  6. Jun 20, 2014 #5


    Staff: Mentor

    Use Thread.sleep:

    Code (Text):

    try {

        Thread.sleep(1000); // SLEEP for 1 second ie 1000 ms

    } catch (InterruptedException e) {


  7. Jun 20, 2014 #6
    I don't think there's a way to slow down java, unless you wrote the code and have access to it to modify it.

    If you can find the DOS version, you can use DOSbox, which I believe has some options to throttle the speed of emulation on more modern PC's, though it can be kind of a pain to configure.

    If you do have the source code (if you did the port), the above advice is pretty solid.
  8. Jun 20, 2014 #7
    Yes, the source code is there on the site i linked. Let me give this a try.
  9. Jun 20, 2014 #8


    User Avatar

    Staff: Mentor

    Computer getting fast are such a pain. At some point all programs written in Turbo Pascal and using crt module stopped to work. From what I remember they were checking how many runs of an internal loop were required per millisecond, that was later used in some kind of sleep() function. Once the integer counter overflowed programs became unpredictable.
  10. Jun 20, 2014 #9
    You could always 2 integers (or more) for the checks on cycles and use conditionals to work around that problem. It's not the most glorious method, but it could work without having to rewrite the entire game while ensuring the timing is correct.

    Also, I didn't realize the source was available in the link (on my phone, and I'm not a fan of mobile browsing), so I apologize for not checking that out before posting.
  11. Jul 8, 2014 #10
  12. Aug 12, 2014 #11
    I used to love that game, its a variation of "game of life", predator/pray simulation. Good luck.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook