#include "vision.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> getVisionPattern1d()
{
    return {1,2,1,1,3,1,1,1,3};
}

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

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

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