United Kingdom
Asked — Edited
Resolved Resolved by Rich!

Searching For Glyphs

Hi guys and galls,

I am writing a script for K9, that depending on which glyph he sees first determines what he does next. now I am taking this step by step to increase my learning of ez script, so the plan is as follows.

When asked to "patrol", he wanders off and looks for glyph 3, then moves on looking for glyph 4, then glyph 2, then back home to glyph 1, with actions at the stops.

Now I have written what I believe to be the code and uploaded to the cloud, but, I just want a sense check to see if this is the right direction, or is there a better way to do this.

Thanks in advance for your patience whilst I am learning :-)


ARC Pro

Upgrade to ARC Pro

Unleash your robot's full potential with the cutting-edge features and intuitive programming offered by Synthiam ARC Pro.

#9  

I wouldn't mind except I really don't have much time today... It is something that I would have to sit down and think about for a while before putting "pen to paper" so to speak...

I'll have to get back to you...

United Kingdom
#10  

OK thanks Richard, i will have a play later, but anything that you can do is much appreciated.

you are definitely an asset the the forum as a friend and a source of knowledge

:)

United Kingdom
#11  

It always sounds more complicated than it is. The reality of it is that each glyph would have a variable set, i.e. $Glyph1Seen = 1

Each Glyph would begin with

IF($Glyph1Seen = 1)

This way, if unseen the script wouldn't run. Or use 0 not 1 and if it hasn't seen it run some code...

For glyph 2 it;s as simple as

IF($Glyph1Seen = 0)
  # Keep searching for Glyph 1 and stop this script
  HALT()
Else
  # Do whatever Glyph does & Set Glyph 2 to having been seen
  $Glyph2Seen = 1
EndIf

If Glyph1 is unseen (i.e. 0 as set in the init script or script which starts this process) it doesn't do anything for Glyph 2. Use similar for Glyph 3 and 4...

IF($Glyph1Seen = 0 OR $Glyph2Seen = 0 OR $Glyph3Seen = 0)
  # Keep searching for Glyph 1 2 or 3 and stop this script
  HALT()
Else
  # Do whatever Glyph does & Set Glyph 3 to having been seen
  $Glyph3Seen = 1
EndIf

#12  

See... Even I made it more complicated than it has to be....:P

With what Rich has here I think you can get a good start on what you want to accomplish....

Well, have to do some work...

Cheers

United Kingdom
#13  

WOW, that gives me something to get my teeth into. thanks @Rich

once again, thanks @Richard R for your time and patience

i will revert with (hopefully) a video of K9 doing this thing of protecting the DR:)

United Kingdom
#14  

Hi there @Rich,

If I am reading your examples right, the following should work


# k9 leaves tardis glyph 1 and is looking for glyph 2
$Glyph1seen =1
IF ($Glyph2seen = 0 and $Glyph3seen = 1 and Glyph4seen = 1)
# looks just for glyph 2 as1, 3 & 4 are set to seen
Commandcontrol("soundboard", track_2)
#sets glyph 2 to seen
$Glyph2seen = 1
ENDIf

This can tgen be tailored and added as required, what do you think. Am I on the right track.

United Kingdom
#15  

Are you looking for the glyphs in order, i.e. Glyph 1 then 2 then 3 then 4?

Think logically and you'll get it working the way you want. IFs are pure logic and work the same way we think.

For instance, IF you are looking for the glyphs in order. You spot 1, you remember that (so you save it to a variable). You continue looking, you find glyph 3, you think "hmm, did I see glyph 2?), another IF. etc.

To find them in order...

Set the ground work first by adding in some script to the Glyph part of the camera control. Something as simple as; Glyph 1

$glyph = 1

Glyph 2

$glyph = 2

Glyph 3

$glyph = 3

Glyph 4

$glyph = 4

# Reset the seen variables
$glyph1seen = 0
$glyph2seen = 0
$glyph3seen = 0
$glyph4seen = 0

# Reset the last seen glyph
$glyph = 0

# Search for glyphs in order

ControlCommand() # Edit this to start up the roaming script used for hunting glyphs

# Wait until a glyph has been seen
WaitForChange($glyph)

IF($glyph = 1 AND $glyph1seen = 0)
  Say("Found number 1, now where is number 2?")
ELSEIF($glyph = 1 AND $glyph1seen = 1)
  Say("Found number 1 but I need number 2")
ELSEIF($glyph != 1 and $glyph1seen = 0) # Note I am not 100% sure of the != as I never use it, it may be =!
  Say("This isn't number 1, where is number 1?")
ELSEIF($glyph = 2 AND $glyph1seen = 0)
  Say("that's number 2 but I need number 1")
ELSEIF("$glyph = 2 AND $glyph2seen = 1)
  Say("that's number 2, I just saw that one, where is 3?")
ELSEIF("$glyph != 2 AND $glyph2seen = 0)
  Say("That's not number 2, I need number 2")
ELSEIF($glyph = 2 AND $glyph2seen = 0)
  Say("Found number 2, where is number 3")
# and so on
ENDIF

Use of AND and OR in the IF will reduce the number of IFs needed as will correctly ordering them. The IF is read in order and once one IF or ELSEIF returns true it ignores any others below it.

I don't have the time right now to properly think about the best order or the best operators to use in the ifs but hopefully the above should be a start and possibly help you understand that IFs work the same way as we think.

For more than one AND or IF read the statement back and see if it makes sense.

for instance, IF($x < $y AND $y > 100 OR $y > 200) that would only be true if $x was less than y and $y was more than 100 OR if $y was over 200. So if $y was 201 it would be true regardless of if $x was less than $y. If $y was 103 but $x was 104 it would be false.

Hope that's clear. If not, check my topics, I did write one on IFs and how to use them which may help you in your glyph hunt script.

United Kingdom
#16  

thanks Dude, again something to get my teeth into and my head around.

the end concept is to have K9 leave the Tardis (Glyph 1) and then depending upon which of the remaining 3 glyph's he finds does a different routine.

i.e if he leaves the Tardis and locates glyph 4 first he will then attack the dalek and then check on the Dr (Glyph 3) and then return home, but if he spotted the Warning (glyph 2) then he would move on to attack the Dalek and then check on the Dr, returning back to the Tradis after checking on the Dr each time.

i understand that this is a massive programming challenge for me, but if you don't push yourself you don't learn, right.

i totally appreciate all your time a assistance in my journey:)