GroupWinner (gp:GroupName) t:Team extrd gps : map GroupName tosetof Score pre gp insetdom gps post t inset {sc.team | sc inset gps(gp)} and let sct = iota sc inset gps(gp) & sc.team = t in forall sc inset gps(gp) &
sc.team <> t => sct.points > sc.points or
sct.points = sc.points and sct.won > sc.won;
GroupRunnerUp (gp:GroupName) t:Team extrd gps : map GroupName tosetof Score pre gp insetdom gps postlet sc' in set gps(gp) be st true--post_GroupWinner(gp,sc'.team,gps,gps) in t inset {sc.team | sc inset gps(gp) \ {sc'}} and let sct = iota sc inset gps(gp) \ {sc'} & sc.team = t inforall sc inset gps(gp) \ {sc'} &
sc.team <> t => sct.points > sc.points or
sct.points = sc.points and sct.won > sc.won;
-- let stmt - lots of examples presumably
GroupWinner_expl : GroupName ==> Team
GroupWinner_expl (gp) == let sc inset gps(gp) best forall sc' in set gps(gp) \ {sc} &
(sc.points > sc'.points) or
(sc.points = sc'.points and sc.won > sc'.won) inreturn sc.team pre gp insetdom gps;
GroupRunnerUp_expl : GroupName ==> Team
GroupRunnerUp_expl (gp) == def t = GroupWinner(gp) inlet sct = iota sc inset gps(gp) & sc.team = t in let sc inset gps(gp) \ {sct} best forall sc' in set gps(gp) \ {sc,sct} &
(sc.points > sc'.points) or
(sc.points = sc'.points and sc.won > sc'.won) inreturn sc.team pre gp insetdom gps;
-- def stmt
SecondRound_expl : () ==> seqof (Team * Team)
SecondRound_expl () == def winners = { gp |-> GroupWinner_expl(gp) | gp insetdom gps };
runners_up = { gp |-> GroupRunnerUp_expl(gp) | gp insetdom gps} inreturn ([mk_(winners(secondRoundWinners(i)),
runners_up(secondRoundRunnersUp(i))) | i inset {1,...,8}]);
-- assignment to state designator -- c.f. earlier version of Win
Win_sd : Team * Team ==> ()
Win_sd (wt,lt) == let gp insetdom gps best {wt,lt} subset {sc.team | sc inset gps(gp)} in gps(gp) := { if sc.team = wt thenmu(sc, won |-> sc.won + 1,
points |-> sc.points + 3) elseif sc.team = lt thenmu(sc, lost |-> sc.lost + 1) else sc
| sc inset gps(gp)} preexists gp insetdom gps & {wt,lt} subset {sc.team | sc inset gps(gp)};
-- conditional statements
GroupWinner_if : GroupName ==> Team
GroupWinner_if (gp) == if clear_winner(gps(gp)) thenreturn ((iota sc inset gps(gp) & forall sc' in set gps(gp) \ {sc} &
sc.points > sc'.points).team) elseif winner_by_more_wins(gps(gp)) thenreturn ((iota sc inset gps(gp) & forall sc' in set gps(gp) \ {sc} &
(sc.points > sc'.points) or
(sc.points = sc'.points and sc.won > sc'.won)).team) else RandomElement ( {sc.team | sc inset gps(gp) & forall sc' in set gps(gp) &
sc'.points <= sc.points} ) pre gp insetdom gps;
RandomElement : setof Team ==> Team
RandomElement (ts) ==
(dcl t:Team := let t' in set ts in t'; return (t));
public GroupWinner_cases : GroupName ==> Team
GroupWinner_cases (gp) == casestrue:
(clear_winner(gps(gp))) -> return ((iota sc inset gps(gp) & forall sc' in set gps(gp) \ {sc} &
sc.points > sc'.points).team),
(winner_by_more_wins(gps(gp))) -> return ((iota sc inset gps(gp) & forall sc' in set gps(gp) \ {sc} &
(sc.points > sc'.points) or
(sc.points = sc'.points and sc.won > sc'.won)).team),
others -> RandomElement ( {sc.team | sc inset gps(gp) & forall sc' in set gps(gp) &
sc'.points <= sc.points} ) end pre gp insetdom gps;
-- for loops
GroupWinners: () ==> setof Team
GroupWinners () ==
(dcl winners : setof Team := {}; forall gp insetdom gps do
(dcl winner: Team := GroupWinner(gp);
winners := winners union {winner}
); return winners
);
end GroupPhase class UseGP
instancevariables
gp : GroupPhase := new GroupPhase()
traces
InitBeforePlay : let t1 inset {<Brazil>, <Norway>, <Morocco>, <Scotland>} in let t2 inset {<Brazil>, <Norway>, <Morocco>, <Scotland>} \ {t1} in let t3 inset {<Brazil>, <Norway>, <Morocco>, <Scotland>} \ {t1,t2} in let t4 inset {<Brazil>, <Norway>, <Morocco>, <Scotland>} \ {t1,t2,t3} in
(gp.Win(t1,t2);gp.Win(t1,t3);gp.Win(t1,t4);gp.Win(t2,t3);
gp.Win(t2,t4);gp.Win(t3,t4);gp.GroupWinner_cases(<A>)
)
end UseGP
¤ Dauer der Verarbeitung: 0.13 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.