# Wanted: A Very Accurate Timer

Discussion in 'Electronic Repair' started by [email protected], Jun 24, 2005.

1. ### 2.comGuest

Personal experience perhaps?

Sigh...

OK. Here we go.

There are 3 or 4 gamers in the U.S. who have confirmed ability to play
the classic game Ms.Pac-man all the way to the end(133 mazes), while
consuming *all* of the bonus prizes and monsters along the way.

The problem is that our highest scores vary by as much as 100,000
points. So the scores cannot really be a determining factor as far as
who the best in the world is at this game, because we have all
accomplished the same thing. We cannot go further thanks to the game's
end.

Our varying high scores are attributed to the "random" aspects of the
game. There are 252 "random" bonus prizes in a complete game, and these
prizes vary in value from 100 points(Cherry) to 5,000 points(Bananna).
register that determines which bonus prizes appear at any given time
incriments 60 times a second. So in 7/60th of a second it will
incriment through all 7 bonus prizes before beginning again. And the
last joystick input before the dot that triggers the prize output is
eaten is responsible for which prize appears. Now if a player could
determine the exact 1/60th of a second a number corresponding to the
5,000 point prize would be the selection *and* had the timing to
activate the correct joystick input at that exact 60th of a second,
that player would be able to make nothing but Banannas appear
throughout the whole game. But of course this is not humanly possible.
So basically the game uses human inconsistency to randomize the prize
output.

There is however an anomaly in the odds. Each of the 7 bonus prizes *do
not* have a 1 in 7 chance of appearing because of the way the
Ms.Pac-man programming code was written.(See below)...

Cherry 0 7 14 21 28
Strawberry 1 8 15 22 29
Orange 2 9 16 23 30
Pretzel 3 10 17 24 31
Apple 4 11 18 25
Pear 5 12 19 26
Banana 6 13 20 27

The register runs through all 32 incriments in just over half a second.
As you can see, all prizes have corresponding numbers. The sequence
goes from 0 to 31, and continually repeats without a pause, skip, or
reset from the time the game is powered on to when it is powered off.

***Unfortunately, the high bonus prizes(Apple, Pear, & Bananna) are
shortchanged in that last line. So as a result the average complete
game score is 874,342.5 points instead of the 905,280 points that it
would be if the odds were in fact 1 in 7 for each prize. The *actual*
odds of getting each prize is shown as fractions and percents here:

Odds of Appearance
******************
Cherry 100 points = 5/32 = 15.625%
Strawberry 200 points = 5/32 = 15.625%
Orange 500 points = 5/32 = 15.625%
Pretzel 700 points = 5/32 = 15.625%
Apple 1,000 points = 4/32 = 12.5%
Pear 2,000 points = 4/32 = 12.5%
Banana 5,000 points = 4/32 = 12.5%

As I mentioned consistently reacting within 1/60th of a second is not
possible, but 1/20th of a second can be achieved with *relative*
consistency, which should be enough to shift the scoring odds ever so
slightly. I say 1/20th because the numbers representing the high value
prizes(Apple, Pear, and Bananna) run through the register within that
amount of time. Determining the exact instant this happens will be
possible through a series of visually references. Since each maze
produces two prizes, and the speeds of game's character movements are
consistent throughout the game. And since we have and can create maze
patterns that run from before the appearance of the first prize to
after the appearance of the second, the exact time the first prize
appears, what it is,and possibly it's travel pattern will make it the
the second prize appears.

***So the last joystick movement before the dot that triggers the
second prize will be the key.

Since our maze patterns have a lot of pauses, the possibility of
resuming motion at the exact same time a particular second on the
display clicks over is doable with some accuracy above and beyond
rolling the dice.(It's a matter of how many times we can hit this high
speed window over the course of a 5 or 6 hour game).

Even a 25% accuracy of hitting that 1/20th of a second window will add
an average of over 45,000 points to one's scores, with a large
deviation either way.(This is rough math). This would greatly increase
the probability of moving the world record up on the game.

Also, another idea involves aiming for the larger 27/60th of a second
window that the prizes do have an equal chance of occurring, thereby
effectively cutting out the register numbers of 28 to 31. This of
course would be much easier to do, and automatically adds about 31,000
points to one's average score.

As far as drift in the game's hardware timimg, this has already been
specific prize, and then making adjustments for the second prize.

The bottom line is that there will be a lot of human error as far as
timing is concerned, but the player with the *least* amount of errors
should have a higher scoring average over time.

***So it is logical to want to minimize the inconsistency of whatever
timing device is used for reference as much as possible. A second on
the display that doesn't click over accurately within 1/60th of a
second will add it's deviation to that of the human errors which will
already be plentiful. So obviously, the more accuarte the timer is, the
better.

Now that was the dumbed-down explanation of my already twice simplified
project.(I'll have to work my way back to the automatic pattern
generator in the future).

Darren Harris
Staten Island, New York.

2. ### NSMGuest

What would occur to me first is to replicate the game on a PC and build
whatever timing or scoring you need into the PC software.

N

3. ### James WaldbyGuest

[Perhaps drop the newsgroup that isn't sci.electronics.design]

....

I didn't see where game hardware timing drift was considered.
Did I overlook something about drift in what you wrote?

Anyhow, this timing problem looks complex enough -- it looks like the
timer may need to slightly speed up or slow down, or to keep track
of scoring and joystick events -- that the best approach would be
a PC- or micro-based timing program. Let PTP="PC timing program".

You want PTP to provide a seconds metronome, to signal the Banana
zone of each second. To make it actually work, I think PTP would
need to know timestamps and values for your joystick inputs and
for scoring. (See * re getting this info.) With that data, PTP
can get syncronized and accomodate for drift. For example,
suppose you do some joystick movement x and then 5 cycles later
the score goes up 500 points; this tells PTP Orange was on the
bonus timer 5/60 seconds ago. After a while PTP can figure out
where Ms.Pac-man is in its 0...31 bonus timer cycle. If, 123
seconds later, Orange is showing up a cycle early relative to PTP,
then PTP increases its per-second delay count by 1 part in 60*123.
PTP should have an adjustable reaction-time offset for different
synchronization phase, and re-sync whenever player tells it to.

* Getting event data: Of course you could set up a board with
several pushbuttons on it and enter data that way, or have an
assistant do so. This might work if you don't have to sync very
often. Also you could attach mercury-switch sensors to wrists
or perhaps to an elastic band that fits on the joystick. For
definitive scoring detection, aim a TV camera at the screen
area where score appears, and decode it in real time. Or if
the game is running on the same computer as PTP, your program
can monitor some bytes of screen memory.
-jiw

Incidentally, regarding the \$49 ebay item
http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=7526393893
(Datum bc620AT ISA time and frequency counter card) that I
mentioned a few days ago, there is a manual for it at
http://www.symmttm.com/pdf/Bus/um_bc620_627at.pdf .
This card looks fairly involved to program, and if you were
to use it I'm not sure whether it would be better to use
the programmable frequency output (pp. 38-39, p. 51) or the
time coincidence strobe (p. 31) or the 1 pps output (p. 11).
Stability is listed as < 2 ms per hour; long term accuracy
can be improved by inputting a 1 pps signal from a GPS unit.
-jiw

4. ### 2.comGuest

Yes you did. Whent you mentioned drift five days ago, I said, "I'm
aware of the consistency of the game hardware. And this project can't
involve tapping into the games clock."
Thanks for the advice but this has to be a "real world" experiment. As
I mentioned it involves going for the world record on Ms.Pac-man, so
the gaming hardware cannot be tapped into to or changed in any way. The
player is the only interface, and info can only be received visually
from the games monitor screen and the the timer's display. This all
comes down to human timing.

BTW Here is some info I uncovered on that acrd you mentioned: "When
DM2000 was first released in 1996, the time synchronization hardware
used was a Datum BC620AT card and time synchronization software from
the Windows NT* Server Resource Kit. The hardware had a potential
problem with the GPS week rollover issue. This time synchronization
software has not been tested by the vendor for year 2000 issues. As a
result of these issues, and because the system was difficult to set up,
we no longer offer this solution."

Darren Harris
Staten Island, New York.

5. ### Guest

First, I should admit that my rant may have been a bit harsh. This may
also have been caused by some ignorant people looking for free help on
some illegal stuff (so their questions were very vague and ill defined)
in another newsgroup that I read. I should have only tried to make the
point the input you get is as detailed as the description of the
problem. There was some suspicion your problem being not exactly as you
described, so you would be looking for another solution to solve it in a
proper way. I was just trying to explain the way people react to the
question, I suppose.

Anyway, on topic, I'd like to explain why I stated you should be
sampling at least 120 times a second if you really want to detect
changes that could be occuring 60 times a second. Suppose you take a
sample 60 times a second. Worst case scenario is that a change occurs
immediately after your sample and a next change occurs exactly before
your next sample. You've missed the entire event in that case. The
second-worst case being that a change occurs immediately after your
sample and you record it almost 1/60th of a second after it really
occured.

6. ### Rich GriseGuest

Thanks for the judicious snip.

You can get the source code here: http://www.mame.net/
but you have to have a license for the ROMs. I think I have
a de facto license for game ROMs, since I used to repair them
for a living, and the company copied them routinely so the owners/
operators could have spares.

Pac-Man, however, for some reason, is almost impossible to find, unless
you have an actual physical game that you can pull the ROMs from - and if
you have that level of access, just solder a wire onto the nearest clock,
and clock your joystick sniffer in sync, or whenever you want to.

Lessee....

Have Fun!
Rich
(I also once had to fix an NSM jukebox... ;-) )

7. ### Rich GriseGuest

Then, if you can't hack the physical game, you'll have to do it the
same way everybody else does:

Practice, practice, practice. ;-)

(Although, somebody could probably come up with a little receiver,
that could sniff clock transitions...)

But if you're intending to cheat in a real-live competition, where
there's the possibility of money exchanging hands, I'd venture to
speculate that most of the regulars of s.e.d would shy away from
such shenanigans. )-;

Good Luck!
Rich

8. ### 2.comGuest

You know, you speculate, imagine, and assume way too much...

Darren Harris
Staten Isalnd, New York.

9. ### 2.comGuest

You know, you speculate, imagine, and assume way too much...

Darren Harris
Staten Island, New York.

10. ### Guest

You left room for that ;-) allthough I did enjoy and appreciate your
explanation. Sounds like an interestig project, so good luck!