Newer
Older
AlgebraicDataflowArchitectureModel / AlgebraicDataflowArchitectureModel / models / JumpGame.model
channel CIO {
	out force(f:Tuple, gravity(y:Double)) == tuple(0.0, y)
	out time(t:Double, gravity(y)) == t + 0.01
	out force(f, e) == f2
	out time(t, e) == t
}

channel CIO2 {
	out move(v:Tuple, moveX(x:Double)) == tuple(x, snd(v))
	out move(v, moveY(y:Double)) == tuple(fst(v), y)
	out move(v, e) == v2
}

channel CIO3 {
	out mass(m:Double, setMass(x:Double)) == x
	out mass(m, e) == m
}

channel CIO4 {
	out ground(g:Bool, openHole) == false
	out ground(g, closeHole) == true
	out ground(g, e) == g
}

channel C1 {
	in force(f, update1(f2, m2)) == f2
	in mass(m, update1(f2, m2)) == m2
	out acceleration(a:Tuple, update1(f2, m2)) == tuple(fst(f2) / m2, snd(f2) / m2)
}

channel C2 {
	ref position(p, update2(p, g2))
	in ground(g, update2(p, g2)) == g2
	out onground(o:Bool, update2(p, g2)) == and(eq(g2, true), le(snd(p), 0.0))
}

channel C3 {
	in acceleration(a, update3(a2, o2)) == a2
	in onground(o, update3(a2, o2)) == o2
	out velocity(v:Tuple, update3(a2, o2)) == if(and(o2, lt(snd(v), 0.0)), tuple(fst(v) + 0.01 * fst(a2), 0.0), 
																		   tuple(fst(v) + 0.01 * fst(a2), snd(v) + 0.01 * snd(a2)))
}

channel C4 {
	in move(m, update4(m2, o2)) == m2
	in onground(o, update4(m2, o2)) == o2
	out velocity(v:Tuple, update4(m2, o2)) == if(o2, m2, v)
}

channel C5 {
	in velocity(v, update5(v2, o2)) == v2
	in onground(o, update5(v2, o2)) == o2
	out position(p:Tuple, update5(v2, o2)) == if(and(o2, lt(snd(p), 0.0)), tuple(fst(p) + 0.01 * fst(v2), 0.0), 
																		   tuple(fst(p) + 0.01 * fst(v2), snd(p) + 0.01 * snd(v2)))
}

channel C6 {
	in position(p, update6(p2)) == p2
	out clear(c:Bool, update6(p2)) == if(gt(fst(p2), 100.0), true, false)
	out gameover(g:Bool, update6(p2)) == if(lt(snd(p2), -1.0), true, false)
}