Open effa opened 7 years ago
Do we have any ideas for "tasks with functions"? I do not. (But I did not try hard yet.)
Simplest example which comes to my mind (it might require some tuning to become a good tasks):
|b |b |b |b |b |
|k |k |kA|r |k |
|k |k |r |k |k |
|kA|kA|rM|kA|kA|
|k |k |r |k |k |
|k |k |kA|r |k |
|k |k |r |k |k |
|k |k |rS|k |k |
with limit of 6 action blocks + start and detour header blocks. Function call probably needs to count as an action, otherwise a student could (generally) just use functions to wrap single actions to save on the action limit. Possible solution:
def start():
detour()
shoot()
detour()
def detour():
fly()
right()
left()
I think that the problem is that for function to be required, it must be either called more than two times or it must contain more than two actions. One solution to this problem is to have a separate aciton limit for each function (incl. start). It would for example allow for the following more advanced task with start (limit 4) and right_left function (limit 2).
|b |b |b |bD|b |
|k |k |k |kD|k |
|kW|k |k |k |kD|
|k |kD|k |kD|k |
|kD|k |k |kD|k |
|k |kD|k |kD|k |
|kD|k |k |rD|k |
|k |kD|k |k |kD|
|kS|k |k |kW|k |
The first task is quite nice, but still can be solved without functions (using different path, so you could forbid it by adding more A's .... just to illustrate that it is not easy to really require functions):
fly()
right()
left()
shoot()
right()
repeat 2:
fly()
"either called more than two times or it must contain more than two actions" - there should be AND (instead of OR), shouldn't?
separate action limit - that does not seem natural/nice
I think that OR is correct: in the first task example (with added rocks/diamonds to enforce the red path), you call the detour function only twice, but since it has more than 2 actions, you need to use it. If you have C calls of function containing A actions, than replacing function calls with the function body increases the total number of actions by C A - (C + A), so you need this value to be greater than zero, right? So at least C or A must be 3 (and the other at least 2 - oh, maybe you meant this and*?)
I think that action limits are generally not very natural/nice, but personally don't see too much difference between per program and per function limits. Consider Robotanik, there are limits per function (on the total length, not actions), not per whole program and it feels natural. Also in real life, whole system can be arbitrarily large, but individual functions should be kept short.
I have new solution to the original task... no functions and just 4 actions...
repeat 2:
fly()
right()
left()
if color() == 'r':
shoot()
Just to illustrate that it will be hard to come up with problems where functions are really necessary (and the word is still reasonably simple).
(Then create some tasks with functions.)