F
forever a loser
Guest
I wrote a console application (that calls and invokes many console functions of the Win32 API) to simulate the behavior of the A* heuristic algorithm in artificial intelligence.
In this console application the user can create any maze with source (the entry to maze) and destination (the exit from maze) and then save the maze to a folder and then later load it from a folder.
There are two browsers so the user can both select and choose where to save his/her maze and which maze to load to the memory of the console application.
The canvas (a matrix of CHAR_INFO passed as a parameter to the WriteConsoleOutputW function) is both saved and loaded properly.
Also the source COORD and destination COORD are both saved and loaded properly, but the obstacles matrix is not.
The obstacles matrix is a boolean matrix that tells if there is an obstacle in a (X,Y) COORD.
In memory, the obstacles matrix is simply an array of C++ bool type that is allocated as new bool[size].
In the debugger I do see that both the width and the height of the obstacles matrix are both saved and loaded properly, but not the content of the obstacles matrix.
It seems that the prefix of the obstacles matrix is all true and the suffix of the obstacles matrix is all false.
I use three functions of the std::wofstream class to save everything to files.
The first function is open, the second is is_open and the third is write.
I also use the three functions of the std::wifstream class to load everything from files.
The first function is open, the second is is_open and the third is read.
When I replace these two classes with _wfopen, fwrite, fread and fclose functions, everything is saved and loaded properly, even the obstacles matrix.
It seems that the C functions are better to use than the C++ std classes and functions.
Am I correct?
By the way that I did not forget to create and open the files in binary mode.
Continue reading...
In this console application the user can create any maze with source (the entry to maze) and destination (the exit from maze) and then save the maze to a folder and then later load it from a folder.
There are two browsers so the user can both select and choose where to save his/her maze and which maze to load to the memory of the console application.
The canvas (a matrix of CHAR_INFO passed as a parameter to the WriteConsoleOutputW function) is both saved and loaded properly.
Also the source COORD and destination COORD are both saved and loaded properly, but the obstacles matrix is not.
The obstacles matrix is a boolean matrix that tells if there is an obstacle in a (X,Y) COORD.
In memory, the obstacles matrix is simply an array of C++ bool type that is allocated as new bool[size].
In the debugger I do see that both the width and the height of the obstacles matrix are both saved and loaded properly, but not the content of the obstacles matrix.
It seems that the prefix of the obstacles matrix is all true and the suffix of the obstacles matrix is all false.
I use three functions of the std::wofstream class to save everything to files.
The first function is open, the second is is_open and the third is write.
I also use the three functions of the std::wifstream class to load everything from files.
The first function is open, the second is is_open and the third is read.
When I replace these two classes with _wfopen, fwrite, fread and fclose functions, everything is saved and loaded properly, even the obstacles matrix.
It seems that the C functions are better to use than the C++ std classes and functions.
Am I correct?
By the way that I did not forget to create and open the files in binary mode.
Continue reading...