Keeping Track of Assists

Hello everyone,
I am currently working on a web app to mimic the alliance station possession and assist monitor for practice. I am having trouble thinking of a way to keep track of assists. As I have it now, most scenarios shown in this video work as they should, however some don’t.
This is my current method for keeping track:

            if(robotNum == 'robot1' && zone == 'red' && !redZone && !rOneAssist) {
                $('#' + robotNum).children('.' + zone).addClass('assist');
                redZone = true;
                rOneAssist = true;
            }
            else if(robotNum == 'robot1' && zone == 'white' && !whiteZone && !rOneAssist) {
                $('#' + robotNum).children('.' + zone).addClass('assist');
                whiteZone = true;
                rOneAssist = true;
            }
            else if(robotNum == 'robot1' && zone == 'blue' && !blueZone && !rOneAssist) {
                $('#' + robotNum).children('.' + zone).addClass('assist');
                blueZone = true;
                rOneAssist = true;
            }
            else if(robotNum == 'robot2' && zone == 'blue' && !blueZone && !rTwoAssist) {
                $('#' + robotNum).children('.' + zone).addClass('assist');
                blueZone = true;
                rTwoAssist = true;
            }
            else if(robotNum == 'robot2' && zone == 'white' && !whiteZone && !rTwoAssist) {
                $('#' + robotNum).children('.' + zone).addClass('assist');
                whiteZone = true;
                rTwoAssist = true;
            }
            else if(robotNum == 'robot2' && zone == 'red' && !redZone && !rTwoAssist) {
                $('#' + robotNum).children('.' + zone).addClass('assist');
                redZone = true;
                rTwoAssist = true;
            }
            else if(robotNum == 'robot3' && zone == 'blue' && !blueZone && !rThreeAssist) {
                $('#' + robotNum).children('.' + zone).addClass('assist');
                blueZone = true;
                rThreeAssist = true;
            }
            else if(robotNum == 'robot3' && zone == 'white' && !whiteZone && !rThreeAssist) {
                $('#' + robotNum).children('.' + zone).addClass('assist');
                whiteZone = true;
                rThreeAssist = true;
            }
            else if(robotNum == 'robot3' && zone == 'red' && !redZone && !rThreeAssist) {
                $('#' + robotNum).children('.' + zone).addClass('assist');
                redZone = true;
                rThreeAssist = true;
            }

Basically, the way it works is whenever the possession of the ball changes, it checks if that zone has already had an assist, and if that robot has had an assist. The problem comes from the example at 3:10 of the video, when the awarded possession changes robots. Does anybody have a better formula for doing this?
Assists are a very confusing part of the game, which is one of the reasons why this is difficult for me to wrap my head around.

How about this:

  1. Make a list of all pairs of all robot/zone combinations
  2. Make all permutations of these items that are length 3 or less
  3. Remove anything that uses the same robot or the same zone more than once
  4. Output the max length of anything that’s left

Few questions:

  1. Does the list contain only the combinations since the start of the cycle, or all possible combinations(9)?
  2. Could you explain how I would then permute that list?
  3. How would I use the max length to determine which robot gets the assist?

Thanks for your help!

To make the method that I mentioned more concrete, here’s a C++ implementation. Note that it hasn’t been optimized at all and uses C++11 features.

assist.cpp (1.49 KB)


assist.cpp (1.49 KB)

The rules don’t create an unambigous way to assign assists to robots. They just say what the allowed combinations are and that you choose the one that gives the most points.

For example, if both robot A and robot B each hold the ball but each only holds it in the white zone who should get the credit? It doesn’t matter for scoring.

I know that which robot gets the assist doesn’t matter, however, I am trying the simulate the alliance monitor, which does show which robot got the assist, and where.

Since FIRST doesn’t release the details to make it work exactly the same as their implementation, I would try to make it the most reasonable way and not spend too much time worrying if it matches exactly.

I would re-evaluate at each possession/zone change and use whichever gives the highest score at that time. If there are multiple permutations with the same score, I would use the same combination that was used in the last evaluation.

Would somebody be able to explain the permutation process?
Do I permutate each combination of robot/zone (r1red, r2white…) or each object (r1, red, r2, white…)?

Have you tried running the code? I think that if you print out the data structures as it runs it might become more clear.

I have run the code, however I’m not exactly fluent in c++, so it is hard for me to figure out what and how to print the correct things.

Ok, try this.

assist.cpp (2.24 KB)


assist.cpp (2.24 KB)