Canada
Asked — Edited
Resolved Resolved by Dunning-Kruger!

How To Keep Score

I am writing a script for playing a game with my robot. I am stumped on what to put in the script to keep score. How would i do that? Thanks


ARC Pro

Upgrade to ARC Pro

ARC Pro is your gateway to a community of like-minded robot enthusiasts and professionals, all united by a passion for advanced robot programming.

#9  

InMoov cheats! Here's what I have at the beginning of my script to set the variables;


ControlCommand("Auto Position", AutoPositionAction, "Readyset")
Sleep(5000)
$inmoov = "inmoov = 0"
$human = "human = 0"
# get a response value
$x = 0
RepeatWhile($x < 5)
$x++
$response = GetRandomUnique(0,3)

it's adding up correctly but saying the wrong thing.


113: if($inmoov>$human)
114: sayezb("I won, nice game")
119: endif
120: Print("My score is "+$inmoov)
> My score is inmoov = 0
121: Print("Your score is "+$human)
> Your score is human = 011111

On this one InMoov announced he won.

United Kingdom
#10  

Every time you use the script

$human = $human + 1

You are effectively only adding a 1 to the end of the string. "Human = 0" + 1 is "Human = 01".

It is saying the correct thing for what you are asking to to say. What you are asking for is not the same as what you want.

Your variables for the scoring aren't decimal they are strings. The lines of code should be;

$inmoov = 0
$human = 0

These are decimal and you will be able to use math with them. You cannot use math with strings.

With these lines of code $human + 1 would be 1, then 2, then 3 as the variable is a number not a string.

#11  

oops sorry Bob... Rich is right, I made a mistake...

before your game set your variables like this... then start the game...


$human=0
$inmoov=0

#12  

Thank you both for all your help with this.