Solved

[c++]  event driven programming

Posted on 2007-11-26
5
887 Views
Last Modified: 2011-10-03
I don't exactly know what this term means,


for instance, to write a program to simulate a mouse trying to go through a maze, and I treat the mouse with sensors,  how do I write the thing that keeps reading the data coming in from it's sensors and then decide on what to do next?

0
Comment
Question by:Troudeloup
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 1

Assisted Solution

by:yyyc186
yyyc186 earned 150 total points
ID: 20354563
Please define what you mean by "simulate a mouse trying to go through a maze" and "sensors".

Is this a homework problem?
0
 
LVL 4

Assisted Solution

by:Ichijo
Ichijo earned 100 total points
ID: 20354683
An example of an event-driven maze traversal program for a sensor-equipped mouse would be, instead of telling the mouse to move one step and then check to see if it has bumped into something, you just tell it to walk straight until told otherwise. Then you have an event handler procedure that will run automatically whenever a collision event occurs (when the mouse bumps into a wall). Your event handler might tell the mouse to change direction, or take some other action of your choice.
0
 
LVL 1

Assisted Solution

by:yyyc186
yyyc186 earned 150 total points
ID: 20354727
You also need to check for possible turns reading those "sensors" or you will never get out of the maze if there is a turn not at a wall.

----------| |----------
|                             |
-------------------------

Once you get into something that looks like the above, you cannot get out.
0
 
LVL 86

Assisted Solution

by:jkr
jkr earned 100 total points
ID: 20355417
You basically nee to implement the concept of a "state machine" (see e.g. http://en.wikipedia.org/wiki/State_machine), that is software that given to a current state (e.g. "moving right") reacts to a signal ("wall approaching") with a predefined reaction (e.g. "turning left"). How that is done in detail is up to the constraints you are facing, thus it is hard to give any more specific advise.
0
 
LVL 53

Accepted Solution

by:
Infinity08 earned 150 total points
ID: 20356348
>> event driven programming
>> I don't exactly know what this term means,

It's a programming technique that defines the flow of the program based on user actions or other (usually external) events (like messages, etc.). For example, if the user clicks a mouse, then some routine is executed to handle the mouse click event.

Or in other words, there's no execution from beginning to end, like a classic program would do ... instead the program is just sitting there, waiting for events, and whenever an event occurs, the proper action is taken to handle that event.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question