I would like to calculate the following in my app:
It’s about the penalty shootout in football. Two teams compete against each other and have 5 attempts. The teams take turns against each other. If both teams have already shot three times and it is 3: 0, you do not need to continue.
Even if it is 0-2 and Team B shoots another goal, and a few other circumstances that cause both teams do not have to shoot 5 times. For this there would have to be a rule / formula that could replace all if-then eventualities simply and logically.
Unfortunately, I can not think of anything that includes all eventualities well. If it is 5: 5, it goes on. Both teams continue to shoot and if it is not a draw then a team wins.
Unfortunately I’m pretty bad in math. Maybe someone has a hint.
To Process "Attempt.TeamA"
set Counter.AttemptsTeamA + 1
IF attempt.success = true
set Score.TeamA + 1
IF ScoreTeamA > ScoreTeamB
set TeamLeading.score to get.ScoreTeamA
set TeamNotLeading.score to get.ScoreTeamB
set TeamNotLeading.attemps to get attemptsTeamB
else set TeamLeading.score to get.ScoreTeamB
set TeamNotLeading.score to get.ScoreTeamA
set TeamNotLeading.attempts to get attemptsTeamA
IF TeamLeading.score - TeamNotLeading.score > 2 AND TeamNotLeading.attempts > 2
then call.Process "END OF GAME"
else call.Process "AfterAttempt"
of course I have no idea of coding (that’s why I am using Kodular) but I like it. I can’t stop smiling right now, but it is like a monkey after an attempt to recreate a Picasso to get a banana.
Rather than attempt at launching into semantic discussion (“al-jabr” is supposed to mean “reunion of broken parts” in the context of “bone setting”), I would propose that this hinges on what being “bad at math” means for most people.
And what an algorithm means.
Making a cake is an algorithm, it is a ordered sequence of things to do; but very little math is involved, as far as most people would define math.
That is why I pointed at the difference.
These blocks are working properly in every possible situation except a 4:2 with 1 attempt left for back team. I am working on this (should be easy)
I cannot use remaining attempts because the remaining attempts (5) will exceed if draw after 5 attempts. If leading team scores, back team maybe is allowed to make a last attempt.