LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to make a maze in Labview

Hi,

 

I am absolutely new to programming and Labview in particular, which is taught in my university. We've been taught all the basics of Labview but now we have been given a project in which we have to design a maze game. We must make a maze, have a character and a treasure on the maze, be able to control the character to get to the treasure whilst there are baddies on the maze to catch you, and also whilst the treasure on the maze move, and be able to configure the difficulty of the maze. I've been trying to research this for hours and hours and I'm still pretty much as empty as when I started.

 

Are there any helpful tips or pointers people can give me, or books to read/ places to research.

 

Thank You

0 Kudos
Message 1 of 13
(5,356 Views)

That's a pretty complicated assignment for school! Sounds fun, though.

 

You should start with the basics just to get an idea of what LabVIEW is capable of. Once you have a starting point with the programming language itself, you can use it however you'd like.

"Give me six hours to chop down a tree and I will spend the first four sharpening the axe."  - Abraham Lincoln

Here are some free training tools primarily focused on LabVIEW and NI hardware to help get started.

NI Learning Center

NI Getting Started

-Hardware Basics

-MyRIO Project Essentials Guide (lots of good simple circuits with links to youtube demonstrations)

-LabVEW Basics

-DAQ Application Tutorials

-cRIO Developer's Guide

Learn NI Training Resource Videos

3 Hour LabVIEW Introduction

6 Hour LabVIEW Introduction
Self Paced training for students
Self Paced training beginner to advanced, SSP Required
LabVIEW Wiki on Training

 

As far as your specific assignment goes, you'll probably have to create a picture indicator that you can think about like an array of color values. A red pixel can be the user going through the maze, white pixels can be the walls, green pixels could be baddies. All of this could be controlled using a Simple State Machine architecture with user events.

 

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


Message 2 of 13
(5,340 Views)

Thanks for your reply.

 

I did a lot of reading up on the State Machine and I can see how that would definately be useful in the later stages of the maze.

I'm still not sure on how to actually make the initial map i.e. how do I make a 30 x 30 grid where I can program in what a 'wall' is and where the player/treasure/baddies spawn?

0 Kudos
Message 3 of 13
(5,287 Views)

Soooo, you've basically been asked to rewrite Pac-Man? Cool, but I agree with James it's a relatively complicated ask for a beginner task. I also agree with him on the importance of going through the training material.

 

Some pointers:

 

  1. I would suggest a 2D array of picture rings or picture controls to display the maze, where each element is a cell in the maze.
  2. I would suggest a 2D array of typedef enums to represent the structure of the maze. There's actually a maze solving example shipping with LV and that's kinda the mechanism it uses. Populating and manipulating the maze becomes a matter of interacting with these enums.
  3. I would suggest a cluster with a shift register to maintain the state of the system.
  4. An event structure can help you with getting user input (mouse down for configuring the maze, key down for movement).
  5. Use all of those to separate the UI from the state. Maintain the state using a clear representation and only convert it to a display when you actually need to show something to the user. This is the thing which is easiest to get wrong - tying what you see in the UI directly to what you have in the code.

___________________
Try to take over the world!
Message 4 of 13
(5,273 Views)

The project is a little tough but im in university studying Computer Engineering so I didnt expect any less!

 

I also agree on running through all the training first. My university has registered me so I can do the self-paced training session online.

 

Thanks for the pointers tst. Now I know where to start and can work my way up

Message 5 of 13
(5,259 Views)

@Mechasaiyan wrote:

The project is a little tough but im in university studying Computer Engineering so I didnt expect any less!


That's the spirit!

As a fun note: On NI Week this year they had a PacMan clone running on a Compact RIO in the mess hall. 🙂

As far as the maze goes, Tst's 2D array-suggestion is good. The maze itself it basically a boolean array, there's a wall or there's not. When a character moves it can move in any direction not hindered by a wall (check against the maze).

Ofcourse the project says nothing about PacMan so it leaves a lot of room for creativity. You can have a "run to the next map" which dynamically generates a map and so on.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 6 of 13
(5,248 Views)

@Mechasaiyan wrote:

im in university studying Computer Engineering


Interesting. It's unusual to see LV in the computer science part of academia. What kind of engineering is it?


___________________
Try to take over the world!
0 Kudos
Message 7 of 13
(5,233 Views)

Look at the example called Queue Stack Maze Solver.vi.  It won't handle the full set of variables you need to use in your more advance game but it might give you some ideas on the maze creation itself t get you started.  Plus, you will surely get bonus points for your grade if you have an AI-based "Auto-Solve" function in your game. Smiley Wink

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019 - Unfortunately now moving back to C#, .NET, Python due to forced change to subscription model by NI. 8^{
Message 8 of 13
(5,187 Views)

tst wrote:
Interesting. It's unusual to see LV in the computer science part of academia. What kind of engineering is it?


 

 

I'm studying Electronics and Computer Engineering. This was an optional module out of 4 others. I've done some programming on other software; C, matlab and a bit of Java. The graphical coding of this software somewhat enticed me.

 

 


 

NIquist wrote:

 Plus, you will surely get bonus points for your grade if you have an AI-based "Auto-Solve" function in your game. Smiley Wink


 

I forgot to mention having an auto solver which the user can choose to show/hide is a must Smiley Very Happy

0 Kudos
Message 9 of 13
(5,153 Views)

Looks like you're in good shape with NIquist's maze solver for the maze part of it.

 

Combine that with this Etch-a-Sketch imitation and you can probably work out how to navigate the maze using arrow keys.

 

I'm curious how this program will function when you're all done. The combination of baddies moving around and auto-solver should result in a different solution each time. Do you need the baddies to move around? If so, you could just add a Timeout case to your event structure that moves them around.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


Message 10 of 13
(5,134 Views)