#include "vision.h"
#include <bits/stdc++.h>

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

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

    if(v[m]==2)
    {
        if(v[m+2]==3)return m+2;
        return m-2;
    }

    if(v[m]==3)
    {
        if(v[m+3]==2)return m+3;
        return m-3;
    }
}

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

std::pair<int, int> getMove2d(std::vector<std::vector<int>> v)
{
    int m=(v.size()/2);
    int c=v[m][m];
    if(c==1)
    {
        if(v[m][m+1]!=1)return {m,m+1};
        if(v[m][m-1]!=1)return {m,m-1};
        if(v[m+1][m]!=1)return {m+1,m};
        return {m-1,m};
    }

    if(c==2)
    {
        if(v[m][m+1]==3)return {m,m+1};
        if(v[m][m-1]==3)return {m,m-1};
        if(v[m+1][m]==3)return {m+1,m};
        return {m-1,m};
    }

    if(c==3)
    {
        int x=0,y=0;
        if(v[m-1][m]==2)y=m+3;
        else y=m-2;
        if(v[m][m-1]==2)x=m+3;
        else x=m-3;
        return {x,y};
    }
}
