#include <iostream>
using namespace std;

#include "path.hpp"
#include "./macro/tile.h"

#define w 7
#define h 5
char map[w*h+1] =
"......."\
".s..#.."\
"...#..."\
"..#..g."\
".......";


void printmap(const char * m)
{
    for (int j=0;j<w*h;j++)
    {
        cout << '[' << *(m+j) << ']';
        if (j%w == w-1)
            cout <<endl;
    }
    for (int j=0;j<w;j++)
        cout << "_";
    cout << endl;
}

void recursive(char* map, int index, int cost)
{
    if (*(map+index) == '#' ||
        *(map+index) == 'g')
        return;
    if (*(map+index) != '.' &&
        *(map+index) != 's' &&
        *(map+index) < (cost<10?cost+48:cost+64) )
        return;
    if (*(map+index) != 's')
        *(map+index) = cost<10?cost+48:cost+64;
    if(haveUp(index,w,h))
        recursive(map,up(index,w,h), cost+1);
    if(haveDown(index,w,h))
        recursive(map,down(index,w,h), cost+1);
    if(haveLeft(index,w,h))
        recursive(map,left(index,w,h), cost+1);
    if(haveRight(index,w,h))
        recursive(map,right(index,w,h), cost+1);
}

int main()
{
    printmap(map);
    
    recursive(map,8,0);
//    
    printmap(map);
//    for (int i=0;i<w*h;i++)
//        cout << i << " right " <<  right(i,w,h) << " have right " << (haveRight(i,w,h)?"yes":"no") << endl;

    return 0;
}
