Asked
— Edited
I want to make my robot able to choose yes or no by itself. I made this script but theres something wrong with it because I can't save it.Code:
$Yes=0
$No=0
$choice1 = GetRandom(0,1)
If $choice1= $Yes
Controlcommand("script manager", scriptstart, "Yes")
Else If $choice1= $No
Controlcommand("script manager", scriptstart, "No")
ENDIF
Also, it should be ElseIf not Else If.
Good practice is to use a 0 for off, false or no and 1 for on, true or yes.
Try;
Code:
That said, the Yes & No variables are redundant really, I'd just do this;
Code:
is the correct syntax, you forgot the brackets.Code:
FYI, the code should be (for anyone who searches and for you if needed)
Code:
While it's not required since the code doesn't go anywhere after the EndIf you could add in some Halt() commands to ensure the script ends...
Code:
Code:
Or if you wanted to use the routine within a script rather than to call a yes or no script;
Code:
Or if you want the decision code to be a separate script you can pause the main script like;
Code:
And the decision script;
Code:
If it's not obvious the scripts above still need some work and fine tuning for whatever the task is and however the confidence and likelihood is fetched. But it's the bones to put the meat on.
I think I got a little carried away but I needed a short break
Code:
What can I do to fix it?
Provided the random number generated for the variable $response is less than it's confidence it should answer yes. Set $confidence at 100 and try it.
Code:
That will always answer yes.
You can also add the variable monitor control and look at what $response is when it's being picked. If it's always answering no it is always picking a number higher than $confidence
Let me know how you get on. If you still have trouble let me have a look at the project as something else may be causing it to always say no.