[code]
class AStar
{
private:
static const int tablesize = 10;
struct node
{
int num;
node* next;
};
node* table[tablesize][tablesize]; //matrix of nodes
int h_value;
std::vector<int>open;
std::vector<int>closed;
Code:
void AStar::generate_board()
{
for (int i=0; i<tablesize; ++i)
{
for (int j = 0; j<tablesize; j++)
{
table[i][j] = new node;
table[i][j]->num = 0;
table[i][j]->next = NULL;
}
}
for (int i =0; i<tablesize; ++i)
{
std::cout<<std::setw(6)<<i;
}
std::cout<<" Columns\n\n";
int k =0;
for (int i = 0; i<tablesize+1; i++)
{
std::cout<<"-----|";
}
std::cout<<"\n\n";
for (int i=0; i<tablesize; i++)
{
for (int j=0; j<tablesize; j++)
{
k++;
table[i][j]->num=k; //assigns values to each node 1-100
std::cout<<std::setw(6)<<table[i][j]->num;
}
std::cout<<" \n";
}
}
Now that I have made a matrix of nodes I plan on taking the values assigned to each node to help calculate the Heuristic. I am slowly getting there but before I go off track I just wanted to share some of my ideas to see if I was overthinking things again or if there was a better way to tackle it.
I read about this in my AI class and it is really bugging me that I am having a hard time programming it. I am doing this on the side so this might take a little time to complete. However I cannot wait until I get it to work.
The scheme of how the program will work is like this:
The user creates barriers by entering the values, then the finish and start points.
After the the program runs and replaces the value with a char X showing the path.