#include "vision.h"


// 1- 60

int a=1,b=2,c=3, ddd=4, e=5, f=6, g=7, h=8, i=9;
std::vector<int> getVisionPattern1d()
{
    return {a, b, c};
}


int getMove1d(std::vector<int> v)
{

    int mid = v.size()/2;
    if ( v[mid] == a && v[mid+1] == b ) return mid+1;
    else if (  v[mid] == a && v[mid-1] == b )  return mid-1;

     if ( v[mid] == b && v[mid+1] == c ) return mid+1;
    else if (  v[mid] == b && v[mid-1] == c )  return mid-1;

     if ( v[mid] == c && v[mid+1] == a ) return mid+1;
    else if (  v[mid] == c && v[mid-1] == a )  return mid-1;
}

std::vector<std::vector<int>> getVisionPattern2d()
{
    return {{a, b, c}, {ddd, e, f}, {g, h, i}};
}

std::pair<int, int> getMove2d(std::vector<std::vector<int>> v)
{
    int midr = v.size()/2;
    int midc = v[0].size()/2;

    int dr = 1;
    int dc = 1;
    if ( v[midr+1][midc] - v[midr][midc] == 3 ||  v[midr+1][midc] - v[midr][midc] == -6  ) dr = 1;
    if ( v[midr-1][midc] - v[midr][midc] == 3  || v[midr-1][midc] - v[midr][midc] == -6 ) dr = -1;

     if ( v[midr][midc+1] - v[midr][midc] == 1 ||  v[midr][midc+1] - v[midr][midc] == -2  ) dc = 1;
    if ( v[midr][midc-1] - v[midr][midc] == 1  || v[midr][midc-1] - v[midr][midc] == -2 ) dc = -1;

    return {midr+dr, midc+dc};
}
