Programmer gurus, logic help needed

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • youngsc
    Restricted User
    • 06-10-08
    • 212

    #1
    Programmer gurus, logic help needed
    For those of you guys that write software to help with your data crunching I'm hoping you can give me some ideas or direction, I've hit writer's block with this for some reason. I'm trying to come up with the logic I would need to use in baseball to figure out if a team has played a 3 or 4 game series. If your currently doing this how? Not looking for the code so much just the logic your using to get there. If you got code then I'm using vb.net however if you give me C# examples that's great too.

    If this isn't in the right section, apologies it seemed like a think tank question.
  • Justin7
    SBR Hall of Famer
    • 07-31-06
    • 8577

    #2
    In game n, check the 3 games before, and the 3 games after. However many matchups there are for the current opponent at the current stadium, that is the series length.
    Comment
    • youngsc
      Restricted User
      • 06-10-08
      • 212

      #3
      I gotcha, only thing is that I'm iterating through a dictionary so it makes it real difficult to do that. I'll have to rethink how I'm storing the data. Thanks for the idea
      Comment
      • JoeVig
        SBR Wise Guy
        • 01-11-08
        • 772

        #4
        What is the dictionary key?
        Comment
        • youngsc
          Restricted User
          • 06-10-08
          • 212

          #5
          Right now it's an arbitrary key that I create based on the date and home team. Since it had to be unique I went that way however that could certainly be changed. What do you use or recommend as a key?
          Comment
          • JoeVig
            SBR Wise Guy
            • 01-11-08
            • 772

            #6
            Check out SortedList type instead of Dictionary type and you can probably use your same key, then your series games will be adjacent in the list.
            Comment
            • youngsc
              Restricted User
              • 06-10-08
              • 212

              #7
              Cool beans thanks, I'll check into it.
              Comment
              • Bsims
                SBR Wise Guy
                • 02-03-09
                • 827

                #8
                Originally posted by youngsc
                Right now it's an arbitrary key that I create based on the date and home team. Since it had to be unique I went that way however that could certainly be changed. What do you use or recommend as a key?
                The key I use to identify a game is;

                yyyymmddvvvhhh#

                the yyymmdd is obviously the date of the game

                vvv is a standard abbreviation for the visiting team

                hhh is a standard abbreviation for the home team

                # is normally 0. It is 1 for the first game of a DH and 2 for the second game.

                I use a similar key for all other sports (execept for the # since only baseball has double headers).
                Comment
                • youngsc
                  Restricted User
                  • 06-10-08
                  • 212

                  #9
                  Originally posted by Bsims
                  The key I use to identify a game is;

                  yyyymmddvvvhhh#

                  the yyymmdd is obviously the date of the game

                  vvv is a standard abbreviation for the visiting team

                  hhh is a standard abbreviation for the home team

                  # is normally 0. It is 1 for the first game of a DH and 2 for the second game.

                  I use a similar key for all other sports (execept for the # since only baseball has double headers).

                  That's a good idea, I can make that change pretty easy. Have you done anything with finding series results in baseball? If so what does your logic statement look like? I can look at it on a spreadsheet and say ok here's the answer but for some damn reason I can't seem to wrap my head around building the logic to tell the computer to do it.
                  Comment
                  • sycoogtit
                    SBR Sharp
                    • 02-11-10
                    • 322

                    #10
                    Code:
                    my $last_opponent;
                    my $last_loc;
                    my $series_length;
                    for my $game (@games) {
                       my ($opponent, $loc) = parse_game($game);
                       if ($opponent eq $last_opponent && $loc eq $last_loc) {
                          $series_length++;
                          print "found series of length $series_length\n" if $series_length >= 3;
                       } else {
                          $series_length = 0;
                       }
                       $last_opponent = $opponent;
                       $last_loc = $loc;
                    }
                    Yay or nay?
                    Comment
                    • Bsims
                      SBR Wise Guy
                      • 02-03-09
                      • 827

                      #11
                      Originally posted by youngsc
                      That's a good idea, I can make that change pretty easy. Have you done anything with finding series results in baseball? If so what does your logic statement look like? I can look at it on a spreadsheet and say ok here's the answer but for some damn reason I can't seem to wrap my head around building the logic to tell the computer to do it.
                      Nope, never had a reason to.
                      Comment
                      • youngsc
                        Restricted User
                        • 06-10-08
                        • 212

                        #12
                        Originally posted by sycoogtit
                        Code:
                        my $last_opponent;
                        my $last_loc;
                        my $series_length;
                        for my $game (@games) {
                           my ($opponent, $loc) = parse_game($game);
                           if ($opponent eq $last_opponent && $loc eq $last_loc) {
                              $series_length++;
                              print "found series of length $series_length\n" if $series_length >= 3;
                           } else {
                              $series_length = 0;
                           }
                           $last_opponent = $opponent;
                           $last_loc = $loc;
                        }
                        Yay or nay?
                        Is that php? At the very least it may make the light go off. It seems to be getting dimmer the older I get and the more beers I drink lol.

                        Originally posted by Bsims
                        Nope, never had a reason to.
                        Cool, thanks for your suggestions though.

                        I asked on another programming forum I'm a member of and one of the gurus suggests I establish separate classes and methods to help with it.

                        All good ideas so I got some studying to do this weekend.

                        As a side what I'm trying to gather is league what the stats for teams sweeping series and then specifically by teams, leagues, etc.
                        Comment
                        • ljump12
                          SBR High Roller
                          • 12-08-09
                          • 113

                          #13
                          it's perl.
                          Comment
                          • MonkeyF0cker
                            SBR Posting Legend
                            • 06-12-07
                            • 12144

                            #14
                            Where are you pulling the data from? If you created a SQL database with the data, it would be much more efficient to run SQL queries. I'm not really sure what you're working with for data, but if you were to define a structure with all of your variables, create an array of that structure, and populate it with your data, you can iterate through the array and search for specific criteria. However, that method is far more complex than simply populating a database table and running a query.
                            Comment
                            SBR Contests
                            Collapse
                            Top-Rated US Sportsbooks
                            Collapse
                            Working...