Skip to content

Feat/scoreline predictions points grading#974

Merged
Olowodarey merged 8 commits into
Arena1X:mainfrom
strngecloud:feat/scoreline-predictions-points-grading
Jun 17, 2026
Merged

Feat/scoreline predictions points grading#974
Olowodarey merged 8 commits into
Arena1X:mainfrom
strngecloud:feat/scoreline-predictions-points-grading

Conversation

@strngecloud

Copy link
Copy Markdown
Contributor

Exact Scoreline Predictions with Points Grading (#966)

Overview

Implements exact scoreline predictions with automatic points grading. Users can now predict exact match scores (e.g., "Arsenal 2 – Chelsea 1") instead of just the 1X2 result, earning bonus points for accuracy.

closes #966

Scoring System

  • 0 points: Wrong 1X2 result
  • 1 point: Correct 1X2 result, wrong scoreline
  • 4 points: Exact scoreline (1 for result + 3 for exact score)

Changes

Storage Types (src/storage_types.rs)

  • Added home_score: Option<u32> and away_score: Option<u32> to Match struct
  • Added predicted_home_score: u32 and predicted_away_score: u32 to Prediction struct
  • Added points_earned: Option<u32> and is_correct: Option<bool> to Prediction struct
  • Defined scoring constants: POINTS_CORRECT_RESULT=1, POINTS_EXACT_SCORE=3
  • Implemented MatchResult::from_scores(home, away) helper to derive 1X2 result from scoreline
  • Implemented Prediction::grade(actual_home, actual_away) for automatic grading

Prediction Submission (src/prediction.rs)

  • Changed submit_prediction() signature: (predictor, match_id, predicted_home_score, predicted_away_score)
  • Automatically derives predicted_outcome from scores (no user input)
  • Removed outcome validation check (now compile-time safe)

Oracle Match Results (src/oracle.rs)

  • Changed submit_match_result() signature: (caller, match_id, home_score, away_score)
  • Automatically derives winning_team from scores
  • Grades all predictions immediately after result submission
  • Updated get_user_score() return: (total_points, correct_results, exact_scores, total_matches)

Contract Interface (src/lib.rs)

  • Updated submit_prediction() contract method
  • Updated submit_match_result() contract method
  • Updated get_user_score() documentation

Testing

  • All 537+ tests passing
  • 15 new scoreline-specific integration tests in submit_match_result_contract_tests.rs
  • Tests validate:
    • Exact score predictions award 4 points
    • Correct result/wrong score awards 1 point
    • Wrong result awards 0 points
    • All outcomes (Team A win, Team B win, Draw) work correctly
    • Points aggregate correctly across multiple matches
    • get_user_score() returns accurate statistics

Acceptance Criteria ✓

  • submit_prediction() takes scoreline (home_score, away_score)
  • submit_match_result() takes final scoreline (home_score, away_score)
  • Grading awards 0/1/4 points per specification
  • get_user_score() returns (total_points, correct_results, exact_scores, total_matches)
  • Prediction.points_earned is None until graded, then Some(0|1|4)
  • Comprehensive test coverage

Migration Notes

This is a breaking change to the prediction API:

  • Old: submit_prediction(predictor, match_id, outcome_symbol)
  • New: submit_prediction(predictor, match_id, home_score, away_score)

Callers must be updated to pass scores instead of outcome symbols.

Files Changed

  • src/storage_types.rs - Data structure updates
  • src/prediction.rs - Prediction submission logic
  • src/oracle.rs - Oracle result submission and grading
  • src/lib.rs - Contract interface
  • tests/*.rs - Test suite updates (7 test files)

Commits

  1. 3ec12b49 - Storage types: Add scoreline fields and scoring constants
  2. b1d8d26d - Prediction: Update to scoreline-based submission
  3. 027234b1 - Oracle: Implement scoreline-based results and grading
  4. fc312140 - Contract interface: Update exposed functions
  5. cc60a4c2 - Tests: Update suite for new API

…age types

- Add home_score and away_score fields to Match struct
- Add predicted_home_score and predicted_away_score to Prediction struct
- Add points_earned and is_correct tracking to Prediction struct
- Define POINTS_CORRECT_RESULT=1 and POINTS_EXACT_SCORE=3 constants
- Implement MatchResult::from_scores() helper to derive 1X2 from scoreline
- Implement Prediction::grade() to award 0/1/4 points based on accuracy
…ad of outcome symbol

- Change submit_prediction() signature to take predicted_home_score and predicted_away_score
- Automatically derive predicted_outcome from scores using MatchResult::from_scores()
- Remove user-supplied outcome validation (no longer needed)
- Update Prediction::new() to derive outcome from scoreline
- Maintain backward compatibility with predicted_outcome field for reads
…tomatic prediction grading

- Change submit_match_result() to accept home_score and away_score instead of winning_team symbol
- Derive winning_team automatically from scores using MatchResult::from_scores()
- Store actual scores (home_score, away_score) on Match struct
- Grade all predictions immediately after result submission
- Award 0 points (wrong result), 1 point (correct result/wrong score), or 4 points (exact score)
- Expand get_user_score() to return (total_points, correct_results, exact_scores, total_matches)
- Set is_correct and points_earned on predictions during grading
…predictions

- Update submit_prediction() contract method signature to accept scoreline
- Update submit_match_result() contract method signature to accept scoreline
- Update get_user_score() return documentation for new tuple format
- Maintain error handling and validation logic
- Migrate oracle_tests.rs to use contract client instead of direct storage
- Enable proper grading flow through submit_match_result contract method
- Update get_match_predictions_tests.rs to use scoreline-based predictions
- Fix oracle_tests helper to use client.submit_match_result()
- All 537+ tests passing including 15 new scoreline-specific tests
- Tests validate: exact score (4 pts), correct result (1 pt), wrong result (0 pts)
- Tests verify get_user_score returns correct tuple with points aggregation
@vercel

vercel Bot commented Jun 17, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
insight-arena-4rll Ready Ready Preview, Comment Jun 17, 2026 8:42am

@Olowodarey

Copy link
Copy Markdown
Collaborator

@strngecloud nice work thank you for your contribution

@Olowodarey Olowodarey merged commit a7206e8 into Arena1X:main Jun 17, 2026
4 checks passed
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

Successfully merging this pull request may close these issues.

[Contract]- Scoreline predictions + points-based grading

2 participants