Portal Home > Knowledgebase > Articles Database > Struggling with logic


Struggling with logic




Posted by MMD, 08-20-2007, 05:28 PM
I was wondering if anyone would be so kind as to give me a few pointers when it comes to the logic of the following project. I'm a competent low level PHP programmer, but need to take my skills to the next level with my latest project. Problem is, i'm really at a loss as to the logic I need to use, as i'll now explain. The basic premise of the site is a sports score prediction site. Users signup, become members and then continue to predict their favorite sports team scores. Admins for each league (each league is for a unique team), add the latest game and this is the game everyone is then trying to predict the score of. I can do all of that, but i'm struggling to get my head around the idea of how to then update peoples scores based on the actual result. At the moment, the admin for a league, enters the actual results linked to the game_id - but then i'm stuck. I currently have the following tables in my db. teams: id team members: id username / numerous other details team_id score (used to store their league score) predictions: id member_id game_id score1 (home team score) score2 (away team score) result (overall prediction of result) game: id team_id opposition (away team storage) score1 (actual home team score, updated after the game) score2 (actual away team score, updated after the game) result (actual result, updated after the game) Perhaps someone can write out a brief explanation of the logic I need to implement to; a) compare results vs predictions b) adjust members scores who have predicted correctly Hope that all made sense, and many thanks to anyone who takes a stab at helping me out here. Martin

Posted by foobic, 08-20-2007, 06:59 PM
I'd say your problem is you haven't defined the rules of the game - your program logic should follow easily from them, eg. Score x points for correctly predicting result (home win, away win or draw)Score y bonus points for correct winning margin (winner goals - loser goals)Score z bonus points for exact prediction of score or whatever else you like. Look for the rules of similar games to get more ideas.

Posted by hostcurry, 08-21-2007, 03:43 AM
Can you elaborate more , Exactly what you want ?

Posted by MMD, 08-21-2007, 08:59 AM
Sorry if my first post was perhaps a bit vague. The idea is; The admin puts up the next game, you predict the score/result for the upcoming game, the admin then updates the game with the real score/result. You get 1point for guessing the correct score, and 1 point for the right result. The trouble i'm having is getting my head around the logic involved with comparing the members prediction against an updated game (with scores and results submitted).

Posted by foobic, 08-21-2007, 07:16 PM
Simple suggestion, expand / improve as necessary: points table: id (optional) member_id game_id points When your admin enters a new result ($game_id, $result, $score1, $score2): to find members who predicted the correct result, then for each one: and to find members who predicted the correct score, then for each one:

Posted by MMD, 08-21-2007, 07:20 PM
Looks great, i'll bash away at the second option and see how it goes. Thanks very much for the help.



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
FDCServers outage? (Views: 796)


Language:

LoadingRetrieving latest tweet...

Back to Top Copyright © 2018 DC International LLC. - All Rights Reserved.