Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

need help debugging a MFC 7 prog

Status
Not open for further replies.

C++

Junior Member level 3
Joined
Oct 12, 2004
Messages
29
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
243
hi, i've attatched the project to this post, the left, right, up, and down functions (recursive) aren't working properly. the agent in this project is supposed to go around the maze (no walls, all rooms open, some have holes, there's 1 monster and 1 gold room) looking for the gold, but instead he goes around in a circle.

Thanks for ur help
 

void CWampusDlg::left ()
{
char temp[10] = "";
itoa (x, temp, 10);
start.SetWindowText (temp);
Sleep (speedVal);
itoa (y, temp, 10);
start.SetWindowText (temp);
Sleep (speedVal);
if ((x != 0) && ((maze[y][(x-1)] != '<') && (maze[y][(x-1)] == '>') &&
(maze[y][(x-1)] != '^') && (maze[y][(x-1)] != 'V')))
{

at this point in the program i note that you use x and y values
? where do you get this value
1} they are never passed to the routine
2} they arent setup in the code within the routine so x and y will just equal zero

so it will go around in a circle as in your app zero is a one state


maybe the same for right routine

you must pass a value on

void CWampusDlg::left (int x,int y) etc...

with global values also used for things like arrays
it isnt a good idea to pass them around
the apps main threads
 

    C++

    Points: 2
    Helpful Answer Positive Rating
x and y are declared in the main class, every time the agent makes a move, x and y are updated using updateAgentPosition ().....anyways, i fixed the code, thanks anyways :)
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top