Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.


+7 votes

Let's say we have a missile coming at our wizard and we want to avoid it. By turning left then moving forward. In order for next commend after turning left to be move forward do I just put it after like this: M3L.1F Would the execute in order they are written? or for example once it's see the missile turns left then runs it from begging and will see the missile with in 3 or less again and turn left?

asked in CSC320 by (8 points)

1 Answer

+5 votes
Best answer

I think that the wizards are only allowed to do one action based off of the state and object code that is being identified. So what you would want is if there is a missile, the action is to turn left and set the state to a number in the range allowed (0-9). Once the wizard has turned and is in that state, you could have it move forward one unit when the wizard is in that state. Unfortunately this means that it takes two turns to avoid the missile, but you can have the wizard keep its distance from others so it has time to react.

answered by (8 points)
selected by

Yes, Ehren is right. Wizards can only take precisely ONE action per turn, and that action is determined by scanning through the Wizard's list of rules (left to right), until it finds the first rule that matches the wizard's state # (0-9) and the rule's conditions.

Ehren is also right that you can set up the wizard to do a 2-move sequence by switching to a different state where the rule for that state is to always do the 2nd move in the sequence.