LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Random

Hi everyone, 

 

How to create a program which can search four directions randomly (North, South, East, West). Once south is chosen at first randomly, but it doesn't work, it will be eliminated. Then, there are still have 3 more options to go. If all of these options cannot work, it will come to the lost condition.

 

Many thanks. 

0 Kudos
Message 1 of 15
(2,754 Views)

Hi Christina,

 

You can generate a random number, scale it up with 10 and convert the representation to I16 ( 16 bit integer ). Now You have integers ranging from 0 to 10 and they will appear randomly of you connect an indicator over front panel.

Now, you can choose any four random numbers for your directions and use Event Structure to generate event whenever the your output becomes equal to the chosen numbers. 

Or you can use state machine architecture if you are aware of it. 

 

Regards.


0 Kudos
Message 2 of 15
(2,721 Views)

And as far as searching a particular direction only once is concerned, use FIRST CALL function. 


0 Kudos
Message 3 of 15
(2,719 Views)

This is all I could come up with. I have generated random number and scaled it to 10. I have randomly selected 9 for South, 6 for East, 4 for West and 3 for North.

Whenever the random number generates these number the first time, my corresponding boolean indicators go ON. When ever any number comes up again, the LEDs will stay off.  

 

( snippet from LV12)

 

Original.png


0 Kudos
Message 4 of 15
(2,705 Views)

I think you are working too hard. Create a cluster or array between 0 and 7 (inclusive, use 8 instead of 10). Have the degree you want to search (0 - North (0), 1 - North 45 deg, 2 - West (90), 3 - West 135, etc...). Then just index into the array with the integer and you will have your random search in 4 degrees.

 

You can always increase the number (should be divisible by 4 (4 directions)) with more refine changes.

0 Kudos
Message 5 of 15
(2,691 Views)

@Joseph_Loo wrote:

I think you are working too hard. Create a cluster or array between 0 and 7 (inclusive, use 8 instead of 10). Have the degree you want to search (0 - North (0), 1 - North 45 deg, 2 - West (90), 3 - West 135, etc...). Then just index into the array with the integer and you will have your random search in 4 degrees.

 

You can always increase the number (should be divisible by 4 (4 directions)) with more refine changes.


At least get the directions correct.  East is 90 degrees, west is 270 degrees.  And the in betweens are North-East 45 deg.  But they didn't ask for the seconday directions.

 

 

0 Kudos
Message 6 of 15
(2,685 Views)

@NapDynamite wrote:

 

Original.png



woooooow?

 

 

0 Kudos
Message 7 of 15
(2,679 Views)
search four directions"
@Christinalau wrote:

Hi everyone, 

 

How to create a program which can search four directions randomly (North, South, East, West). Once south is chosen at first randomly, but it doesn't work, it will be eliminated. Then, there are still have 3 more options to go. If all of these options cannot work, it will come to the lost condition.

 

Many thanks. 


What do you mean by "search four directions" and "it doesn't work"?  I can guess that I'm standing in the middle of a grid and I try to move in a direction (search) and if the way is blocked (doesn't work) I look try another direction.  Are you trying to navigate a maze?  I can also guess that randomly searching for a way out of a maze will not work, but I'm no good at statistics.

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 8 of 15
(2,666 Views)

This question was already asked...and i seem to recall it being a homework assignment.

 

http://forums.ni.com/t5/LabVIEW/Maze-solving-Algorithm-Random-search/td-p/2587939/page/2

 

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 9 of 15
(2,665 Views)

If this is for navigating a maze, a random search direction would seem a very poor way to go about it.  I have equal odds of going backwards as I do of going forwards (unless you exclude the direction you just came from).  But if you do this, what happens when you hit a dead end?  

0 Kudos
Message 10 of 15
(2,655 Views)