Basically, I have multiple .cpp files in one program. One .cpp file contains the command
visited.push_back( startSquare ); and i want to use that command in a different .cpp file. The first wfile is ofr course where the array is created, etc.
Can anyone tell me in lamens terms what i need to do in another class if i want to call that array and add to the data?
(i want the command to be using the same array which is visited)
oh no, the array is working fine and the command is working fine.
The command visited.push_back( startSquare ); is in one class, ill call that class
A.cpp
There is no problems.
I want to use the same command in another class, ill call that class
B.cpp
the problem is i don't know what i have to do to allow me to use this command in a different class as the array doesnt exist in the B.cpp and i want to use the same array on both A.cpp and B.cpp. If that makes sense?
ah, because B.cpp deals with generating a board while A.cpp handles the AI movement on it.
the way i've done my code, the ai doesnt step on spaces its been on already i.e. visited.
whenever a movement is made the space the AI is on is added to visited using visited.push_back( x,y );
I want to take that code and use it when generating the board to convince the AI that "walls" are in fact spaces it has previously tried to walk on but failed.
The AI class should do that itself. It is not the responsibility of the board class to inform the AI where it should not walk; the AI should see the board and know where not to walk.
yeh, but yesterday i made the board generate randomly. Other students are making a staple board and thus can keep it all in one class.
The board is basically completely separate to the AI as far as i can tell. At the moment it goes through walls like a ghost. I want to add some code to the generation of the random walls that includes adding the spaces the walls consume as spaces the AI cannot travel on.
How the board is generated is not relevant; the AI should be able to look at the board and detect obstacles. The board should have no idea that the AI even exists.
ah but we are not doing proper AI. The way we have coded it, the "AI" simply moves in a random fashion over and over again, then when it ends up in the right place. It takes that specific path and displays it. But each time if it corners itself, it stops and restarts, that space it stopped on becomes a space it will never try to step on again.
I want to make walls those spaces because the walls are purely visual at the moment and have no relation with the AI.
but the board is randomly generated, the walls are never in the same place. I cant alter the AI constructor because that is in A.cpp/.h and the walls generating code is in B.cpp which is basically my initial problem in reverse. :(
ok, this looks like what i was thinking. I just wasn't sure how exactly you would go about this. Thanks for the help (despite my ignorance), ill let you know how it goes :D