Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Keeping Track of Assists (http://www.chiefdelphi.com/forums/showthread.php?t=124936)

ggorsuch 19-01-2014 22:38

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:


Code:

            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.

SoftwareBug2.0 20-01-2014 00:05

Re: Keeping Track of Assists
 
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

ggorsuch 20-01-2014 00:44

Re: Keeping Track of Assists
 
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!

SoftwareBug2.0 20-01-2014 00:50

Re: Keeping Track of Assists
 
1 Attachment(s)
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.

SoftwareBug2.0 20-01-2014 02:05

Re: Keeping Track of Assists
 
Quote:

Originally Posted by ggorsuch (Post 1329601)
How would I use the max length to determine which robot gets the assist?

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.

ggorsuch 20-01-2014 15:21

Re: Keeping Track of Assists
 
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.

Joe Ross 20-01-2014 15:50

Re: Keeping Track of Assists
 
Quote:

Originally Posted by ggorsuch (Post 1329788)
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.

ggorsuch 20-01-2014 21:57

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...)?

SoftwareBug2.0 21-01-2014 01:10

Re: Keeping Track of Assists
 
Have you tried running the code? I think that if you print out the data structures as it runs it might become more clear.

ggorsuch 21-01-2014 01:17

Re: Keeping Track of Assists
 
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.

SoftwareBug2.0 21-01-2014 02:21

Re: Keeping Track of Assists
 
1 Attachment(s)
Ok, try this.


All times are GMT -5. The time now is 02:33.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi