Originally Posted by
joeprogrammer
Figure out how far along in the game it is, for example, 2nd quarter, then do something like this:
Code:
visitors_final_score=visitors_current_score * ((4/current_quarter)*time_in_quarter + time_in_quarter/remaining_time)/Total_time_in_game;
home_final_score=home_current_score * (4/current_quarter)*time_in_quarter + time_in_quarter/remaining_time)/Total_time_in_game;
(probably too complicated, but you get the idea)
I don't see how this would work... assuming it's the end of the thrid quarter (with no time left in the quarter) and the visitor has 15 points (I'm assuming 30 minute quarters and a two hour game, an that your Total_time_in_game and everything else was in minutes):
Code:
visitors_final_score=15*((4/3)*0+0/30)/120;
that simplifies to
Code:
visitors_final_score=15*(1.3333333*0+0/30)/120;
which then becomes
Code:
visitors_final_score=15*(0+0/30)/120;
and if you can't see the problem by now:
Code:
visitors_final_score=15*(0/30)/120;
of course the program would have bailed out by now, but just to drive it further home:
Code:
visitors_final_score=15*(undef)/120;
=
Code:
visitors_final_score=(undef)/120
oh noes
Code:
=visitors_final_score=(undef)
now, assuming that you mean to use the next quarter if this one is over (same information):
Code:
visitors_final_score=15*((4/4)*30+30/30)/120;
visitors_final_score=15*(1*30+1)/120;
visitors_final_score=15*31/120;
visitors_final_score=3.875;
visitors_final_score=4;
now that can't possibly be right, seeing as they already have 15 points... unless it's customary to lose 11 points in the last quarter of a basketball game...
unless I'm missing something... if you were trying to predict how much the final score would be based off time, the formula would be more like:
Code:
final=static_cast<int>(((score/static_cast<double>(timePlayed))*timeLeft)+score);