70 lines
1.7 KiB
C++
70 lines
1.7 KiB
C++
// The A* implementation used in this code is
|
|
// a modified form of Dijkstra's Algorithm, as
|
|
// see on the YouTube channel "Friendly Developer"
|
|
#include <iostream>
|
|
#include <fstream>
|
|
#include <algorithm>
|
|
#include <vector>
|
|
#include <string>
|
|
#include <sstream>
|
|
|
|
#define INF 10
|
|
|
|
using namespace std;
|
|
|
|
int main(void)
|
|
{
|
|
int arrayXsize, arrayYsize;
|
|
bool finalCode = false;
|
|
if (!finalCode)
|
|
{
|
|
arrayXsize = 10;
|
|
arrayYsize = 10;
|
|
}
|
|
if (finalCode)
|
|
{
|
|
arrayXsize = 100;
|
|
arrayYsize = 100;
|
|
}
|
|
int map[arrayYsize][arrayXsize];
|
|
int distMap[arrayYsize][arrayXsize] = {INF};
|
|
int remainingMap[arrayYsize][arrayXsize];
|
|
for (int i = 0; i < arrayYsize; i++)
|
|
{
|
|
for (int j = 0; j < arrayXsize; j++)
|
|
{
|
|
//shrink xSize and ySize properly, using manhattan dist.
|
|
remainingMap[i][j] = ((arrayXsize - 1) - j) +
|
|
((arrayYsize - 1) - i);
|
|
}
|
|
}
|
|
vector<pair<int,int>> pathThruMap;
|
|
int lineLength = 0;
|
|
int pathCost = 0;
|
|
int xIndex = 0;
|
|
int yIndex = 0;
|
|
int tempInt = 0;
|
|
string rawInput;
|
|
ifstream readFile ("data/testInput.txt", ios::in);
|
|
|
|
while(getline(readFile, rawInput))
|
|
{
|
|
for(int xIndex = 0;
|
|
xIndex < rawInput.size();
|
|
xIndex++)
|
|
{
|
|
tempInt = rawInput[xIndex]-'0';
|
|
map[yIndex][xIndex] = tempInt;
|
|
}
|
|
yIndex++;
|
|
}
|
|
|
|
// Pairs are basically coordinates
|
|
pair<int, int> vectorAddPair;
|
|
// Pairs are initialized as (note namespace);
|
|
vectorAddPair = make_pair(0,0);
|
|
// add pair to vector
|
|
pathThruMap.push_back(vectorAddPair);
|
|
|
|
return 0;
|
|
}
|