Jump to content





RealSports Curling

Posted by AverageSoftware, 17 May 2017 · 260 views

Proof of scoring

 
Well, look at that.  What is it, you ask?
 
Just a memory dump of location $600.  $600 is the scratch area that I'm using for the scoring algorithm.  If you don't know, curling scoring works as follows:
 
The team with the closest rock to the center of the rings scores one point, plus one additional point for each of their rocks that is closer to the center than the other team's closest rock.  Rocks that are outside of the rings don't count, so it's possible that neither team will score.
 
What you see here is a test end in which the yellow team has scored two points.  The first two bytes are ID numbers for the rocks that scored, 0 and 2.  The FF is the list terminator.
 
The scoring algorithm is rather simple.  First, I order the rocks by distance using a sort of insertion sort.  This list is also constructed at $600, with a three byte entry for each rock.  The first two bytes are the distance from the button (the button is the center of the rings), the third byte is the ID number for the rock in that slot.  You can see the remnants of that list beyond the terminating FF.  This particular test scenario only had three rocks.
 
I can then determine which team scored by looking at the ID number of the first rock in the list.  If it's FF, no rocks were eligible for scoring.  Otherwise, I can determine the owner by checking to see if the number is even or odd.
 
I continue down the list checking the ID numbers until either FF comes up, or I get a rock whose even/oddness doesn't match the first rock.  Along the way, I've been pushing the IDs of the scoring rocks onto the stack.
 
Once I have all the scoring rocks, I just pop them off the stack while copying them into successive addresses starting at $600.  Now that I have the rock IDs, I can do something to visually indicate which rocks scored, I'll probably just have them blink.
 
I'm immensely proud that I actually got this working.  It's not perfect yet, there are still some edge cases I need to account for and some tweaking of the distance calculations, but the overall logic is sound.  I also need to more rigorously eliminate rocks that fall outside the rings.  Right now I'm just doing a bright-line test against the front of the rings, but I need something more detailed to hit the corner areas.
 
The "physically correct" answer is to simply have a cutoff distance from the button.  The problem with this is that it might not work correctly when placed up against the relatively low resolution of the 5200 playfield.  Or maybe it will just work!  I need to try it to find out.
 
Either way, just having something that works this poorly is a major milestone in this project.






October 2017

S M T W T F S
1234567
891011121314
15161718192021
22 232425262728
293031    

Recent Entries

Recent Comments

Tags

    Categories