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.
$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
Yes and No both equal 0, the script will only either say Yes or end.
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;
That said, the Yes & No variables are redundant really, I'd just do this;
The IF $choice=1 bit is wrong.(syntax error)
Sorry, I didn't pick up on that error.
is the correct syntax, you forgot the brackets.
I tried this but it just kept on going. it never stopped.
What do you mean it never stopped? There is no loop in the code so it would get through the IF and would stop...
FYI, the code should be (for anyone who searches and for you if needed)
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...
And to make it that little bit better and add in confidence, like @MovieMaker has been wanting for a while you could do something a little bit like this, where $confidence is determined by the question asked in another script;
Or if you wanted to use the routine within a script rather than to call a yes or no script;
Or if you want the decision code to be a separate script you can pause the main script like;
And the decision script;
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
I have experimented with this top one but it doesn't seem to work. it always chooses no.
What can I do to fix it?
Where's it getting it's confidence from?
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.
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
The script works fine. Have a look at this project here. Set the confidence with the slider and start the Yes No Script.
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.
nevermind. I fixed it. changed the value.
I bookmarked this script, it can be very useful method to call. Technopro way to go!