#include "vision.h"
using namespace std;

int nnn=32;

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

int getMove1d(std::vector<int> v)
{
    return 0;
}


std::vector<std::vector<int>> getVisionPattern2d()
{
    vector<vector<int>> p;
    //p.reserve(nnn);
    for(int i=0;i<nnn;i++)
    {
        //p[i].reserve(nnn);
        p.push_back({});
        for(int j=0;j<nnn;j++)p[i].push_back(1);
    }
    for(int i=2;i<=nnn;i*=2)
    {
        for(int j=i-1;j<nnn;j+=i)
        {
            for(int k=i-1;k<nnn;k+=i+i)p[j][k+((j+i+1)%(i+i))]=i;
        }
    }
    p[0][0]=3;
    return p;
}

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