Coding Challenge 4 - The Memory Game
Email your entries to LabVIEWDigestCompetition@ni.com
Deadline - 26th January 2018
This challenge asks you to build a simple memory game. On the VI there is a colour box indicator. Your task is to have it display a growing series of random colours. So we start by displaying one colour, the user inputs the colour using the controls. Then we display the first colour again but add another random colour to the sequence, the user inputs the two colours of the sequence. Then we add a third colour and so on.
The program should:
Please use one of the attached VIs.
I have included an NXG version but colour box constants are not in NXG 1.0 so I have used words instead. The same coding is required, but you display the names of colours, not the actual colour.
Please note the competition is only open to LabVIEW users in Europe, Middle East, India and Africa.
thanks for reminding me about the deadline. I put it in my calendar but not in the post for some reason! It's the 26th January and it's in the post now.
So definitely still plenty of time.
I've also noticed notifications not working as I didn't see Phil's comment until I actually came back to the post. Hopefully that's a temporary thing, I'll flag it up with the web team.
Thanks for this new challenge, it seems a little bit more difficult than the previous, but I prefer like this
I have a question: what do you mean about the fail message "the correct color was XXXX"?
XXXX represent all the colors of the test (in string like Blue, Green ...)? Only the first failed color? The latest color of the test?
Yeah, I thought I'd try and switch between a simple challenge and more of a full application every other time now. As I think it's nice to sometimes think about the structure a bit more, than just develop and algorithm.
So the XXXX should be replaced with whatever colour the person failed at. So yes, the first failed colour.
So if the sequence is Blue, Red, Black and I entered Blue, Green the program should stop the game as soon as I got it wrong and display the message 'the correct colour was Red'.
I hope that makes more sense.
Thank you to everyone that joined in with this challenge! This one was definitely a bit harder than some of the others as I saw a lot of entries that almost worked but didn't quite.
This challenge's winner is user HugoPaul! They had one of the easiest to understand solutions I saw and it was very nicely documented. I believe they're looking to take their CLD so the good documentation practices will come in handy.
The winning code is attached below as I realise the block diagram is hard to see in the images
Key Point of Feedback:
Many solutions relied on a lot of local variables in state machines. Local variables can lead to race conditions which are hard to debug but can cause errors in your code.
Now you should be fine in a state machine as things don't happen in parallel which is where race conditions become likely. But it's really great practice to not use local variables when you don't have to. Even if you get lucky and never have a race condition, it's a lot easier to debug your code when you have wires updating the UI.
Ways to avoid using them in a state machine include only updating an indicator from one state, or updating the indicators after the case structure. Does anyone have other ways to deal with this?
One of the issues with the UI I designed is that it was hard to tell if the same colour came up twice in a row. Thoric had a great solution to this by adding some fancy transitions! Code attached if you want to understand how it works!
when is the next challenge. Is it open for devleopers in india?