Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Discussion] : Data design for states, formats and events of sports. #25

Open
majorbruteforce opened this issue Dec 27, 2024 · 8 comments

Comments

@majorbruteforce
Copy link
Member

No description provided.

@KrishnaKalra
Copy link

KrishnaKalra commented Dec 27, 2024

Match State

const matchState = {
   matchNumber: 5,
   totalMatches: 6,
   pointsToWin: 11,
   currentBallHolder: "playerX",
   first: {
      playingTeam: "CSE",
      totalPoints: 10,
      totalMatchWon: 2,
      playerNo: 2,
      players: {
        player: {
          name: "PlayerA",
          points: 34,
        },
        order: [
          {
            name: "PlayerX",
            points: 0,
            status: "played",
            profileLink: "https://example.com/profile/playerx",
          },
          {
            name: "PlayerY",
            points: 10,
            status: "playing",
            profileLink: "https://example.com/profile/playery",
          },
          {
            name: "PlayerZ",
            points: 0,
            status: "nextToPlay",
            profileLink: "https://example.com/profile/playerz",
          }
        ]
      },
      inningsStatus: "in_progress",
      foulsStatus: null,
      target: null
    },
    second: {
      playingTeam: "IT",
      totalPoints: 10,
      totalMatchWon: 2,
      playerNo: 2,
      players: {
        player: {
          name: "PlayerA",
          points: 34,
        },
        order: [
          {
            name: "PlayerX",
            points: 0,
            status: "played",
            profileLink: "https://example.com/profile/playerx",
          },
          {
            name: "PlayerY",
            points: 10,
            status: "playing",
            profileLink: "https://example.com/profile/playery",
          },
          {
            name: "PlayerZ",
            points: 0,
            status: "nextToPlay",
            profileLink: "https://example.com/profile/playerz",
          }
        ]
      },
      foulsStatus: null,
      target: 10
    },
    interrupted: "match_delay",
    teamACaptain: "CaptainA",
    teamBCaptain: "CaptainB",
    umpires: ["Umpire1", "Umpire2"],
    matchStatus: "in_progress", // Possible values: draw/cancelled
    matchOutcome: [
      null, // Possible values: EEE/IT/draw/no_result
    ]
};

@neoandmatrix
Copy link
Member

neoandmatrix commented Dec 27, 2024

const event25 = {
  type: "fault", 
  details: {
    player: "PlayerB", 
    faultType: "service_fault", // "service_fault", "net_touch", "out_of_bounds"
  },
  timestamp: new Date()
};

Match Event for badminton.

@KrishnaKalra
Copy link

KrishnaKalra commented Dec 27, 2024

Match Event

const event24 = {
  type: "points_scored",
  details: {
    points: 1,
    currentBallHolder:"player2",
    scoringType: "hit", // Possible values: miss, hit, foul
    illegal: "foul", // Indicates foul play
    penalty: 1, // 0 for legal play
  },
  timestamp: new Date()
};


const event = {
  type: "match_won",
  details: {
    team_1_score: 11,
    team_2_score: 5,
    match_result: "Team_1_won" // Possible values: team1, team2, draw
  },
  timestamp: new Date()
};

@neoandmatrix
Copy link
Member

neoandmatrix commented Dec 27, 2024

const matchFormat = {
  totalGames: 3, 
  pointsPerGame: 21, // Each game is played upto 21 points
  pointsToWin: 2, 

  penaltyActions: {
    fault: () => ({
      illegal: "fault",
      penalty: 1
    }),

    misconduct: () => ({
      illegal: "misconduct",
      penalty: 1
    })
  },

  extrasActions: {
    let: () => ({
      type: "let",
      description: "Let: The rally is replayed"
    }),

    serviceOver: () => ({
      type: "service_over",
      description: "Service Over: The serve changes to the opponent"
    })
  },
}

match Format for badminton

@neoandmatrix
Copy link
Member

const matchState = {
    game: {
      currentGame: 1, // Current game number
      totalGames: 3, // Best of 3 games
      score: {
        playerA: 15, // Score of Player A
        playerB: 18 // Score of Player B
      },
      server: "playerA", // Current server
      receiver: "playerB", // Current receiver
      rallies: [
        {
          rallyNumber: 1,
          winner: "playerA",
          description: "Player A won the rally with a smash"
        },
        {
          rallyNumber: 2,
          winner: "playerB",
          description: "Player B won the rally with a drop shot"
        }
      ]
    },
    players: {
      playerA: {
        name: "Player A",
        gamesWon: 0, // Number of games won by Player A
        profileLink: "https://example.com/profile/playerA"
      },
      playerB: {
        name: "Player B",
        gamesWon: 1, // Number of games won by Player B
        profileLink: "https://example.com/profile/playerB"
      }
    }
}


match state badminton

@abir499-ban
Copy link
Contributor

Match Format for Cricket keeping in mind all the Edge Cases:

 const matchFormat = {
  totalOvers: 20,
  powerplayOvers: 6,
  legalDeliveriesPerOver: 6,
  maxOversPerBowler: (totalOvers) => Math.ceil(totalOvers / 5),

  penaltyActions: {
    noBall: () => ({
      illegal: "no_ball",
      freeHit: true,
      penalty: 1,
      additionalPenalty: "runs scored on free-hit count only."
    }),

    wide: () => ({
      illegal: "wide",
      freeHit: false,
      penalty: 1,
      description: "Delivery counts as an extra ball and 1 penalty run added."
    }),

    timeViolation: (team) => ({
      violation: "time_penalty",
      penalty: team === "batting" 
        ? "deduction from total runs" 
        : "extra runs awarded to opposition",
      value: 5
    }),
  },

  extrasActions: {
    byes: (runs) => ({
      type: "byes",
      penalty: runs,
      description: `Byes: ${runs} run(s) awarded for non-intercepted deliveries.`
    }),

    legByes: (runs) => ({
      type: "leg_byes",
      penalty: runs,
      description: `Leg byes: ${runs} run(s) awarded for deflected non-contact deliveries.`
    }),

    overthrow: (runs) => ({
      type: "overthrow",
      bonusRuns: runs,
      description: `Overthrow: ${runs} bonus run(s) due to fielding error.`
    }),
  },

  weatherInterruption: {
    reducedOvers: (remainingOvers) => ({
      situation: "rain_interruption",
      newTotalOvers: remainingOvers,
      rulesApplied: "Duckworth-Lewis-Stern method or other DLS variation."
    }),

    abandonedMatch: () => ({
      outcome: "abandoned",
      result: "No result or reserve day applied."
    })
  },

  applyPowerPlayRestrictions: (overs) => {
    return overs <= matchFormat.powerplayOvers 
      ? "Only two fielders outside the 30-yard circle during powerplay."
      : "Normal fielding restrictions apply after powerplay.";
  },

  tieBreaker: {
    superOver: () => ({
      rule: "Super Over",
      maxBalls: 6,
      maxBatters: 3,
      description: "In case of a tie, teams play one over each to determine the winner."
    }),

    boundaryCount: (team1Boundaries, team2Boundaries) => ({
      rule: "Boundary Count",
      result: team1Boundaries > team2Boundaries 
        ? "Team 1 wins by boundary count" 
        : "Team 2 wins by boundary count."
    })
  },

  playerSubstitution: {
    concussionSubstitution: (player) => ({
      allowed: true,
      description: `${player} can be replaced .`
    }),

  
  },

  fieldingRestrictions: {
    numberOfFieldersOutsideCircle: (overs) => {
      if (overs <= matchFormat.powerplayOvers) return 2;
      else if (overs > matchFormat.powerplayOvers && overs <= matchFormat.totalOvers - 5) return 4;
      return 5; // Death overs
    },

    penaltyForViolation: () => ({
      description: "5 penalty runs for fielding restrictions violations.",
      action: "Ball counted as a no-ball."
    })
  },

  reviewSystem: {
    drs: true,
    maxReviewsPerInnings: 2,
    description: "Teams can use Decision Review System (DRS) up to 2 unsuccessful attempts per innings."
  },

  overRatePenalty: (ratePerHour) => {
    if (ratePerHour < 10) {
      return {
        penalty: "Slow over rate penalty",
        deduction: "One fielder outside 30-yard circle for remaining overs.",
      };
    }
    return {
      status: "Compliant",
      message: "No penalty applied."
    };
  }
};

@majorbruteforce majorbruteforce changed the title [ Discussion ] : Data design for states, formats and events of sports. [Discussion] : Data design for states, formats and events of sports. Dec 30, 2024
@ujsquared
Copy link
Collaborator

Here's matchFormat, matchState and matchEvent for carrom

const matchFormat = {
    match: {
        id: "2024_Carrom_001",
        competition: "Carrom Championship",
        venue: {
            name: "Hall A",
            city: "Mumbai"
        },
        officials: {
            referee: "Referee1"
        },
        startTime: "2024-12-27T15:00:00Z",
        status: "completed"
    },
    teams: {
        teamA: {
            name: "Team A",
            players: [
                { id: "A1", name: "Player1", role: "striker", stats: { successfulShots: 15, fouls: 1, queenCovers: 1 } },
                { id: "A2", name: "Player3", role: "support", stats: { successfulShots: 10, fouls: 0, assists: 1 } }
            ],
            totalPoints: 35,
            fouls: 1
        },
        teamB: {
            name: "Team B",
            players: [
                { id: "B1", name: "Player2", role: "striker", stats: { successfulShots: 12, fouls: 2, queenAttempts: 1 } },
                { id: "B2", name: "Player4", role: "support", stats: { successfulShots: 9, fouls: 0, assists: 0 } }
            ],
            totalPoints: 30,
            fouls: 2
        }
    }
};

const matchEvents = [
    {
        shot: 0,
        player: "A1",
        type: "break",
        outcome: "scatter"
    },
    {
        shot: 1,
        player: "B1",
        type: "pocket",
        outcome: "scoreWhite in corner A"
    },
    {
        shot: 2,
        player: "A2",
        type: "assist",
        outcome: "setup in corner C"
    },
    {
        shot: 3,
        player: "B2",
        type: "foul",
        outcome: "strikeOut"
    },
    {
        shot: 4,
        player: "A1",
        type: "queen capture",
        outcome: "queenCapture with cover in corner B"
    },
    {
        shot: 5,
        player: "B1",
        type: "queen attempt",
        outcome: "miss"
    },
    {
        shot: 6,
        player: "A2",
        type: "pocket",
        outcome: "scoreBlack in corner D"
    },
    {
        shot: 7,
        player: "B2",
        type: "foul",
        outcome: "strikeOut"
    },
    {
        shot: 8,
        player: "A1",
        type: "round end",
        outcome: "teamALead"
    },
    {
        shot: 9,
        player: "B1",
        type: "break",
        outcome: "scatter"
    },
    {
        shot: 10,
        player: "A2",
        type: "pocket",
        outcome: "scoreWhite in corner C"
    },
    {
        shot: 11,
        player: "B2",
        type: "pocket",
        outcome: "scoreBlack in corner A"
    },
    {
        shot: 12,
        player: "A1",
        type: "foul",
        outcome: "scoreOpponentCoin in corner B"
    },
    {
        shot: 13,
        player: "B1",
        type: "pocket",
        outcome: "scoreWhite in corner D"
    },
    {
        shot: 14,
        player: "A2",
        type: "round end",
        outcome: "teamAWin"
    }
];

const matchState = {
    matchOutcome: {
        winner: "teamA",
        type: "points",
        finalScore: {
            teamA: 35,
            teamB: 30
        },
        fouls: {
            teamA: 1,
            teamB: 2
        },
        summary: "Team A clinched victory with superior queen handling and strategic gameplay."
    }
};

@iamanishx
Copy link
Collaborator

iamanishx commented Dec 30, 2024

const matchState = {
    periods: {
      first: {
        startTime: "2024-12-27T15:00:00Z",
        endTime: "2024-12-27T15:45:00Z",
        score: {
          home: 2,
          away: 1
        },
        possession: "60% home",
        addedTime: 2,
        events: [
          {
            timestamp: "2024-12-27T15:23:14Z",
            type: "goal",
            team: "home",
            scorer: {
              name: "PlayerA",
              number: 9,
              assist: {
                name: "PlayerB",
                number: 10
              }
            },
            minute: 23,
            description: "Header from close range"
          }
        ],
        status: "completed"
      },
      second: {
        startTime: "2024-12-27T16:00:00Z",
        endTime: "2024-12-27T16:50:00Z",
        score: {
          home: 1,
          away: 2
        },
        possession: "away",
        addedTime: 4,
        events: [],
        status: "completed"
      },
      extraTime: {
        firstHalf: {
          startTime: "2024-12-27T17:00:00Z",
          endTime: "2024-12-27T17:15:00Z",
          score: {
            home: 0,
            away: 0
          },
          possession: "50% each",
          events: [],
          status: "completed"
        },
        secondHalf: {
          startTime: "2024-12-27T17:20:00Z",
          endTime: "2024-12-27T17:35:00Z",
          score: {
            home: 1,
            away: 1
          },
          possession: "55% home",
          events: [
            {
              timestamp: "2024-12-27T17:30:45Z",
              type: "goal",
              team: "away",
              scorer: {
                name: "PlayerZ",
                number: 11,
                assist: {
                  name: "PlayerY",
                  number: 8
                }
              },
              minute: 110,
              description: "Free kick from outside the box"
            }
          ],
          status: "completed"
        }
      },
      penalties: {
        home: [
          { player: "PlayerA", success: true },
          { player: "PlayerB", success: false },
          { player: "PlayerC", success: true }
        ],
        away: [
          { player: "PlayerX", success: true },
          { player: "PlayerY", success: true },
          { player: "PlayerZ", success: false }
        ],
        outcome: "home", // 'home', 'away', or 'draw'
        score: { home: 2, away: 1 }
      }
    },
    teams: {
      home: {
        name: "Team A",
        formation: "4-3-3",
        captain: "PlayerC",
        lineup: [
          {
            name: "PlayerK",
            number: 1,
            position: "GK",
            status: "playing",
            stats: {
              saves: 3,
              cleanSheets: 0,
              passes: 12,
              passAccuracy: 85
            },
            cards: []
          }
        ],
        substitutes: [
          {
            name: "PlayerL",
            number: 12,
            position: "GK",
            status: "bench"
          }
        ],
        substitutionsLeft: 3,
        cards: {
          yellow: 2,
          red: 0
        },
        injuries: []
      },
      away: {
        name: "Team B",
        formation: "4-4-2",
        captain: "PlayerM",
        lineup: [],
        substitutes: [],
        substitutionsLeft: 2,
        cards: {
          yellow: 1,
          red: 1
        },
        injuries: []
      }
    },
    match: {
      id: "2024_PL_001",
      competition: "Premier League",
      venue: {
        name: "Stadium A",
        city: "London"
      },
      officials: {
        referee: "Referee1",
        assistants: ["Assistant1", "Assistant2"],
        fourthOfficial: "Official4",
        var: {
          referee: "VARRef1",
          assistant: "VARAssist1"
        }
      },
      weather: {
        condition: "clear",
        temperature: 18
      },
      status: "penalties",
      minute: 120 // + penalties
    },
    stats: {
      home: {
        possession: 55,
        shots: {
          total: 12,
          onTarget: 5,
          blocked: 3,
          woodwork: 1
        },
        corners: 6,
        fouls: 8,
        passes: {
          total: 342,
          completed: 298,
          accuracy: 87
        },
        offsides: 2
      },
      away: {
        possession: 45,
        shots: {
          total: 8,
          onTarget: 4,
          blocked: 2,
          woodwork: 0
        },
        corners: 4,
        fouls: 10,
        passes: {
          total: 289,
          completed: 234,
          accuracy: 81
        },
        offsides: 3
      }
    },
    matchOutcome: {
      winner: "home", // 'home', 'away', or null
      type: "penalties",
      score: { home: 2, away: 1 }
    }
  };
  
//Goal event 
const goalEvent = {
    type: "goal",
    details: {
      team: "home",
      scorer: {
        name: "PlayerA",
        number: 9,
        assist: {
          name: "PlayerB",
          number: 10
        }
      },
      minute: 23,
      description: "Header from close range"
    },
    timestamp: new Date()
  };

//Substitution event
const substitutionEvent = {
    type: "substitution",
    details: {
      team: "home",
      outPlayer: {
        name: "PlayerX",
        number: 7
      },
      inPlayer: {
        name: "PlayerY",
        number: 15
      },
      minute: 60
    },
    timestamp: new Date()
  };

//Foul event
const foulEvent = {
    type: "foul",
    details: {
      team: "away",
      player: {
        name: "PlayerM",
        number: 5
      },
      type: "sliding tackle",
      card: "yellow", // yellow/red/none
      minute: 42
    },
    timestamp: new Date()
  };

//injury event
const injuryEvent = {
    type: "injury",
    details: {
      team: "away",
      player: {
        name: "PlayerN",
        number: 3
      },
      severity: "moderate",
      minute: 78
    },
    timestamp: new Date()
  };

//Penalty event
const penaltyEvent = {
    type: "penalty",
    details: {
      team: "home",
      player: {
        name: "PlayerC",
        number: 11
      },
      success: true, // true/false
      minute: 89
    },
    timestamp: new Date()
  };

//VAR event
const varEvent = {
    type: "var_decision",
    details: {
      incident: "offside",
      team: "home",
      player: {
        name: "PlayerZ",
        number: 8
      },
      decision: "goal disallowed",
      minute: 67
    },
    timestamp: new Date()
  };`
   

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants