A PHP Error was encountered
Severity: 8192
Message: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior
Filename: database/DB_driver.php
Line Number: 1876
A PHP Error was encountered
Severity: 8192
Message: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior
Filename: database/DB_driver.php
Line Number: 1876
A PHP Error was encountered
Severity: 8192
Message: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior
Filename: database/DB_driver.php
Line Number: 1876
A PHP Error was encountered
Severity: 8192
Message: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior
Filename: database/DB_driver.php
Line Number: 1876
A PHP Error was encountered
Severity: 8192
Message: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior
Filename: database/DB_driver.php
Line Number: 1876
A PHP Error was encountered
Severity: 8192
Message: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior
Filename: database/DB_driver.php
Line Number: 1876
A PHP Error was encountered
Severity: 8192
Message: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior
Filename: database/DB_driver.php
Line Number: 1876
A PHP Error was encountered
Severity: 8192
Message: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior
Filename: database/DB_driver.php
Line Number: 1876
A PHP Error was encountered
Severity: 8192
Message: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior
Filename: database/DB_driver.php
Line Number: 1876
A PHP Error was encountered
Severity: 8192
Message: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior
Filename: database/DB_driver.php
Line Number: 1876
A PHP Error was encountered
Severity: 8192
Message: Function create_function() is deprecated
Filename: geshi/geshi.php
Line Number: 4751
A PHP Error was encountered
Severity: 8192
Message: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior
Filename: database/DB_driver.php
Line Number: 1876
A PHP Error was encountered
Severity: 8192
Message: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior
Filename: database/DB_driver.php
Line Number: 1876
A PHP Error was encountered
Severity: 8192
Message: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior
Filename: database/DB_driver.php
Line Number: 1876
A PHP Error was encountered
Severity: 8192
Message: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior
Filename: database/DB_driver.php
Line Number: 1876
A PHP Error was encountered
Severity: Warning
Message: Cannot modify header information - headers already sent by (output started at /home/Jenja/www/mcpaste.de/www/system/core/Exceptions.php:272)
Filename: view/download.php
Line Number: 2
A PHP Error was encountered
Severity: Warning
Message: Cannot modify header information - headers already sent by (output started at /home/Jenja/www/mcpaste.de/www/system/core/Exceptions.php:272)
Filename: view/download.php
Line Number: 3
#include
#include
#include
/*
* In der Cell Strucktur werden Ergebnisse aus dem Algorithmus gespeichert
*/
struct Cell
{
bool bMarked; // Zeigt an, ob das Feld schon besucht wurde ( ture = besucht )
int nLastX; // Die X Koordinate des vorherigen Feldes ( -1 = kein vorheriges Feld )
int nLastY; // Die Y Koordinate des vorherigen Feldes
Cell(){
this->bMarked = false;
this->nLastX = -1;
this->nLastY = -1;
}
};
/*
* Die Coordinate Strucktur dient der
*/
struct Coordinate
{
int x, y;
};
// Uninteressant
bool operator<(const Coordinate c1, const Coordinate c2) {
return false;
}
// Uninteressant
bool operator==(const Coordinate c1, const Coordinate c2) {
return false;
}
/*
* In dieser Tabelle steht die Reihenfolge in der die Umliegenden
* Felder abgearbeitet werden sollen
*/
const int DirTable[8][2] = {
{ 0, -1}, // oben
{ 1, 0}, // rechts
{ 0, 1}, // unten
{ -1, 0}, // links
{ 1, -1}, // rechts-oben
{ 1, 1}, // rechts-unten
{ -1, 1}, // links-unten
{ -1, -1} };// links-oben
// Globale Variablen
int heigth; // Hoehe des Konfigurationsraums
int width; // Breite des Konfigurationsraums
BYTE **cspace; // cspace[i][j] gibt die "Farbe" des Konfigurationsraums an
// Die Farben selbst sind in der Funktion SaveAsBitmap als
// Palette definiert. z.B. 1 = Weiss, 2 = Rot, usw. ( siehe unten)
Cell **aCells; // In diesem 2D Feld werden die Ergebisse des Algorithmus abgelegt
// Funktionsprototypen:
bool LoadFromBitmap( char *szFile, BYTE ***array, int *width, int *heigth );
bool SaveAsBitmap( char *szFile, BYTE **array, int width, int heigth );
bool FindPath( int nStartX, int nStartY, int nGoalX, int nGoalY );
void ClearCells();
/*
* main
*/
int main()
{
int x, y;
// Laden des Konfigurationsraums
if( !LoadFromBitmap( "cspace.bmp", &cspace, &width, &heigth ) )
return -1;
// Zellenarray allokieren ( dynamisch auf dem Heap )
aCells = new Cell*[heigth];
for( y=0; y queue;
// Startzelle:
Coordinate c;
c.x = nStartX;
c.y = nStartY;
// Folgende Zeilen demonstrieren die Manipulation von Queues ( Warteschlange )
// Einfach auskommentieren und testen
/* printf("Queue leer ? : %d\n", queue.empty()); // Am Anfang ist die Queue leer
queue.push( c ); // Element in die Queue anstellen
printf("Queue leer ? : %d\n", queue.empty()); // Jetzt sollte die Queue nicht mehr leer sein
printf( "Elemente in Queue: %d\n", queue.size() ); // Anzahl Elemente in der Queue
Coordinate test = queue.front(); // front() gibt das forderste Element in der Queue zur�ck,
printf("x: %d, y: %d\n", test.x, test.y ); // jedoch wird da Element dadurch nicht entfernt!
queue.pop(); // Entfernt das erste Element aus der Queue
printf("Queue leer ? : %d\n", queue.empty()); // Nun sollte die Queue wieder leer sein
*/
// ToDo: Ihr Algorithmus
// ....
queue.push(c);
aCells[c.y][c.x].bMarked = true;
while( !queue.empty() ) // Solange bis keine Elemente mehr in der Queue sind
{
Coordinate currentCell = queue.front();
queue.pop();
if (currentCell.x == nGoalX && currentCell.y == nGoalY){
return true;
}
else{
for (unsigned int i = 0; i < 8; i++){
Coordinate newCell = currentCell;
newCell.x += DirTable[i][1]; // Offset auf die Base Adress rechnen, um zur umliegenden Zelle zu kommen
newCell.y += DirTable[i][0];
int nX = newCell.x;
int nY = newCell.y;
if ((nX < heigth && nY < width) && (nX && nY)){ // Die Zelle liegt noch im Konfigurationsraum
if (!aCells[nY][nX].bMarked){ // Wenn die Zelle noch nicht markiert ist
if (!cspace[nY][nX]){ // Und keine Kollision stattfindet...
aCells[nY][nX].bMarked = true; // aktuelle Zelle als vorg�nger setzten
aCells[nY][nX].nLastX = currentCell.x;
aCells[nY][nX].nLastY = currentCell.y;
queue.push(newCell);
}
}
}
}
}
}
return false; // Default Return
}
/*
* ClearCells()
* Setzt alle Zellen auf die Initialwerte zur�ck
*/
void ClearCells()
{
// Zellen zur�cksetzen
for( int y=0; y=0; y-- )
{
for( x=0; x=0; y-- )
{
for( int x=0; x
A PHP Error was encountered
Severity: 8192
Message: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior
Filename: database/DB_driver.php
Line Number: 1876