Skip to content

Instantly share code, notes, and snippets.

@mattmils
Created July 25, 2011 22:34
Show Gist options
  • Save mattmils/1105423 to your computer and use it in GitHub Desktop.
Save mattmils/1105423 to your computer and use it in GitHub Desktop.
Rematori LTSA
// Matteo Rolla
// matr. 730928
const REM = 3
const NUM = 2
range Ids = 1..NUM
const FALSE = 0
const TRUE = 1
range BOOL = FALSE..TRUE
REMATORE = (
arrivaAlCampo -> iniziaAllenamento -> ALLENA
),
ALLENA = (
rema -> ALLENA | concludiAllenamento -> migliorRematore[b:BOOL] -> CENA[b]
),
CENA[b:BOOL] = (
when (b == TRUE) sonoIlMigliore -> cena -> REMATORE |
when (b == FALSE) nonSonoIlMigliore -> cena -> REMATORE
).
ALLENATORE = A0[0],
// Stato iniziale.
A0[num:0..NUM] = (
// Raduna i rematori al campo.
when (num < NUM) r[Ids].arrivaAlCampo -> A0[num + 1] |
// Inizia l'allenamento.
when (num == NUM) iniziaAllenamento -> A1[0]
),
// Allenamento iniziato.
A1[num:0..REM] = (
// Rema.
when (num < REM) rema -> A1[num + 1] |
// Conclude l'allenamento.
when (num == REM ) concludiAllenamento -> A2[NUM][FALSE]
),
// Allenamento concluso, scelta migliore.
A2[num:0..NUM][c:BOOL] = (
when (num > 1 && c == FALSE)
r[Ids].migliorRematore[TRUE] -> A2[num - 1][TRUE] |
when (num > 1 && c == FALSE)
r[Ids].migliorRematore[FALSE] -> A2[num -1][c] |
when (num > 1 && c == TRUE)
r[Ids].migliorRematore[FALSE] -> A2[num - 1][c] |
when (num == 1 && c == TRUE)
r[Ids].migliorRematore[FALSE] -> A3[0] |
when (num == 1 && c == FALSE)
r[Ids].migliorRematore[TRUE] -> A3[0]
),
// Migliore scelto, cena e conclusione giornata.
A3[num:0..NUM] = (
// Cena.
when (num < NUM) r[Ids].cena -> A3[num + 1] |
// Concludi la giornata.
when (num == NUM) concludiGiornata -> ALLENATORE
).
|| SYS = ( r[Ids]:REMATORE || ALLENATORE )/
{
// Sync dei rematori.
iniziaAllenamento/r[Ids].iniziaAllenamento,
rema/r[Ids].rema,
concludiAllenamento/r[Ids].concludiAllenamento }.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment