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

  • Context: Java 
  • Thread starter Thread starter dkotschessaa
  • Start date Start date
  • Tags Tags
    Dos Java Program
dkotschessaa
Messages
1,063
Reaction score
763
When I was a (very lonely) child, I used to play endlessly with this predator-prey simulation game:
http://www.leinweb.com/snackbar/wator/

(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:

http://en.wikipedia.org/wiki/Wa-Tor

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
 
on Phys.org
dkotschessaa said:
predator-prey simulation game:
How do I play it?
 
Assuming there's a main loop in the game, add an inner loop that just iterates, perhaps with some type of sleep like function.
 
Use a timer with a callback function to the game logic.
 
Use Thread.sleep:

Code:
try {

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

} catch (InterruptedException e) {

    e.printStackTrace();  

}
 
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.
 
jedishrfu said:
Use Thread.sleep:

Code:
try {

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

} catch (InterruptedException e) {

    e.printStackTrace();  

}

elusiveshame said:
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.

Yes, the source code is there on the site i linked. Let me give this a try.
 
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.
 
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
I used to love that game, its a variation of "game of life", predator/pray simulation. Good luck.