#include "vision.h"
//#include "grader.cpp"

std::vector<int> getVisionPattern1d()
{
    return {3,1,2,1,1};
}

int getMove1d(std::vector<int> v)
{
    int m = v.size()/2;
    if(v[m] == 1) {
        if(v[m+1] == 3)return m+1;
        if(v[m-1] == 3)return m-1;
        if(v[m+1] == 2)return m+1;
        if(v[m-1] == 2)return m-1;
    }
    if(v[m] == 2) {
        if(v[0] == 1)return 0;
        if(v[4] == 1)return 4;
    }
    if(v[m] == 3) {
        if(v[1] == 2)return 1;
        else return m+2;
    }
}

std::vector<std::vector<int>> getVisionPattern2d()
{
    return {{5,1,2,1,1},{1,1,2,1,1},{2,2,2,1,1},{1,1,1,1,1},{1,1,1,1,1}};
}

std::pair<int, int> getMove2d(std::vector<std::vector<int>> v)
{
    int m = v.size()/2;
    if(v[m][m] == 5) {
        if(v[m+2][m+2] == 2) return {m+5,m+5};
        if(v[m+2][m-2] == 2) return {m+5,m-5};
        if(v[m-2][m+2] == 2) return {m-5,m+5};
        if(v[m-2][m-2] == 2) return {m-5,m-5};
    }
    for(int i = 0; i < (int)v.size(); i ++ )
        for(int j = 0; j < (int)v.size(); j ++ )
            if(v[i][j] == 5)return {i,j};

    for(int i = 0; i < (int)v.size(); i ++ )
        for(int j = 0; j < (int)v.size(); j ++ )
            if(v[i][j] == 2)return {i,j};
}
