Jump to content

Help Project


Recommended Posts

Hi, I would like to create a project but I am new to Labview. I would like to simulate a penalty shootout where a user chooses a direction to shoot (center, right, or left) and an opposing goalkeeper simulated by a random number generator (ranging from 1 to 3) determines where the goalkeeper dives and if they dive on the same side as the shot, they stop it. When they stop a shot their score increases by 1, but if they don't stop it, the player's score increases by 1 and the game ends when one of the two reaches 5 (with a while loop). The score is displayed in a table with multiple rows and the score's progress is visible through a graph. Could someone give me some advice on how to do this?

Link to comment

it's ok to cross-post, just notify when you do ;)
https://forums.ni.com/t5/Discussions-au-sujet-de-NI/Aide-projet/m-p/4297462#M35675

This sounds like homework, am I right?

Have you started at all to create some code?

My suggestion is you try your best effort to create something as basic as it may be and if you're stuck, post your code (the VI files in a zip) and then we have a base to start helping you.

I'll give you a head start, here's a VI that will generate a random number ranging from 1 to 3.

image.png.e3310b5e254079ff0d4f0ef30484054e.png

Link to comment

Hello, I have indeed started coding. So far, I have tried to create the part where the player chooses to shoot either in the center, right, or left. I associate each direction with a number from 1 to 3 using a switch-case structure, and then compare it to the random number generator. If they are equal, the goalkeeper's score increases by 1, and if they are different, the player wins 1 point. For this, I use a shift register to initialize both scores, and then use two cases for the increment of either score. My problem for now is that both scores increase at the same time, the player's score starts at 1 instead of 0, and another minor issue is that the LED indicating if the goalkeeper stops the shot never turns on. How could I improve and correct these errors?

image.png.997dc6d2ab01d09bcc0802c19c215c0f.png

Link to comment

you have to keep track of the score for the goal-keeper and the score for the player independently, so one shift register for each, both shift registers initailized with 0

 

the while loop is running without any timing control, therefore 'as fast as possible, you'll see this if you create an indicator of the the iteration terminal (the blue square 'i' at the bottom left) of the loop

that's why you never actually see the 'stop' turning on, it goes so fast that you don't see it, if you simply add a 1 second wait timer in the loop you'd see it.

But there are better ways to do the 'processsing' of who gets a point only when you clic on the 'shot' button, take a look at the event structure.

Link to comment

Thank you, you have helped me greatly. I have taken what you have done and redone it myself to understand it. I changed the while loop stop condition so that the match stops when one of the two has reached 10 points. Now I would like to store the scores in a graph and a table that update in real time. For the graph everything works as expected but I can't link the table. Do you have an idea how to make it works. I would also like to put a message that says if the goalkeeper or the player, should I use a case structure and put it at the output of the event structure?

image.png.5f4c8c02a1564d21f7b0515fc0559a8c.png

Link to comment
32 minutes ago, Zlatoun said:

Thank you, you have helped me greatly. I have taken what you have done and redone it myself to understand it. I changed the while loop stop condition so that the match stops when one of the two has reached 10 points. Now I would like to store the scores in a graph and a table that update in real time. For the graph everything works as expected but I can't link the table. Do you have an idea how to make it works. I would also like to put a message that says if the goalkeeper or the player, should I use a case structure and put it at the output of the event structure?

image.png.5f4c8c02a1564d21f7b0515fc0559a8c.png

If you wanted to append running data to table, just use Property Node (value) for Table (Read Existing Table Value and Append the run time value).

For Message use Case Selector and update Goal Keeper/Player inputs.

Link to comment
3 minutes ago, Zlatoun said:

I would like to display once it reaches 10 for the player or the goalkeeper.

 

Use Boolean Array to Number Function, where you will get 0 if nothing is true and 1 if first element of array is true and 2 if second element of array is True and 3 if all two elements are true.

Use case structure and based on 1/2 display Message.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.