To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.roboticsOpen lugnet.robotics in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / 2192
2191  |  2193
Subject: 
Re: Programming the SPIRIT.OCX from VB (random #s?)
Newsgroups: 
lugnet.robotics
Date: 
Sun, 3 Jan 1999 10:33:27 GMT
Original-From: 
Peter Hesketh <pbh@phesk.demon.co=saynotospam=.uk>
Viewed: 
1399 times
  
In article <F4yn8t.Gvx@lugnet.com>, John Cutter
<lugnet.robotics@lugnet.com> writes
[snip]
Specifically, I want to program the robot to, for example, turn it's head
left and then right "X" times, where X = a random number between 1 and 5.

No problem.

Spirit commands (answer in register 31):

.setvar 31, 4, 4    'Get a random (source 4) number between 0 and 4
.sumvar 31, 2, 1    'Add constant 1 to it
'Register 31 now contains a random number 1 to 5


NQC statement:

int rand1to5
rand1to5 = Random(4) + 1

At other times, I'd like to tell the robot to go into "explore" mode for
anywhere from 10 to 250 seconds.


Spirit commands (to put number of seconds in register 31):

.setvar 31, 4, 240   'Get a random (source 4) number between 0 and 240
.sumvar 31, 2,  10   'Add constant 10 to it
'Register 31 now contains a random number 10 to 250


NQC statement:

int rand10to250
rand10to250 = Random(240) + 10


NB: This is all theory, using resources found on the web.  I have never
programmed an RCX in the flesh.  No doubt someone will correct me if I'm
wrong!
--
Regards - Peter Hesketh, Mynyddbach, Mon.
Forty reasons why a dog is better than a woman: number 16
"Dogs like it when you leave lots of things on the floor."
--
Did you check the web site first?: http://www.crynwr.com/lego-robotics



Message is in Reply To:
  Programming the SPIRIT.OCX from VB (random #s?)
 
I thought my original question was fairly clear, but I guess not! I want to program some "random" behaviors for my robot and download them into the RCX. This being the case, I assume that I need to use the "random" register in the RCX, as opposed to (...) (26 years ago, 3-Jan-99, to lugnet.robotics)

2 Messages in This Thread:

Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR