0

I want to control a simulated physical process by increasing/decreasing some variables using the keyboard or pointer. What I can see you must choose either TimePassing() or KeyPress() etc for change(). And I can understand you need two parallel running tasks. Then I start to think of using the "entry point" groupActivityOf(). Can you have two "tasks" or programs running on the same computer? Thus I would then let one task be updated using TimePassing() and the other with KeyPress().

janpeter
  • 681
  • 8
  • 22
  • 2
    Uh. I'm not very familiar with codeworld, but the claim "you must choose either TimePassing() or KeyPress() etc for change()" is a bit extraordinary. Are you sure it's correct? What evidence makes you believe this claim? – Daniel Wagner Oct 23 '21 at 14:27
  • Well, I am rather new to CodeWorld myself. But I see you are right! You can let the function change() have different kind of change, i.e. continuous time for some states and events for others. See my posted answer. – janpeter Oct 23 '21 at 15:42

1 Answers1

1

Daniel made me think differently, and here is an example that illustrate the combination of continuous time (sampled with dt) and events for change of the state, that actually works!

program                           = activityOf(state_0, change, picture)
state_0(rs)                       = (t0,u0)
t0 = 0
u0 = 0
change((t, u), KeyPress("Up"))    = (t, u+1)
change((t, u), KeyPress("Down"))  = (t, u-1)
change((t, u), TimePassing(dt))   = (t+dt, u)
change((t, u), other)             = (t, u)
picture(t, u)                     = pictures [translated(lettering(printed(t)),0,1), lettering(printed(u))]
janpeter
  • 681
  • 8
  • 22