#include "vision.h"

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

int getMove1d(std::vector<int> v)
{
    if(v.size()==3){
        if(v[0]==1 and v[2]==1)return 0;
        if(v[0]==3)return 0;
        if(v[2]==3)return 2;
        if(v[0]==2)return 0;
        return 2;
    }
    if(v.size()==5){
        if(v[0]==3)return 0;
        return 4;
    }
    if(v[1]==2)return 6;
    return 0;
}

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

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