#include "vision.h"

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

std::vector<std::vector<int>> getVisionPattern2d()
{
    vector<vector<int>> v1;
    vector<int> gol;
    gol.clear();
    gol.push_back(1);
    gol.push_back(2);
    gol.push_back(4);
    v1.push_back(gol);
    gol.clear();
    gol.push_back(2);
    gol.push_back(4);
    gol.push_back(1);
    v1.push_back(gol);
    gol.clear();
    gol.push_back(4);
    gol.push_back(1);
    gol.push_back(2);
    v1.push_back(gol);
    return v1;
}
pair<int,int> analiza(int val, int a,std::vector<std::vector<int>> v)
{
    vector<pair<int,int>> v1;
    v1.clear();
    v1.push_back({0,0});
    v1.push_back({0,a});
    v1.push_back({a,0});
    v1.push_back({a,a});
    for(auto it:v1)
    {
        if(v[it.first][it.second]==val)
        return {it.first,it.second};
    }
}
std::pair<int, int> getMove2d(std::vector<std::vector<int>> v)
{
    if(v.size()==3)
    {
        return analiza(4,2,v);
    }
    if(v.size()==5)
    {
        return analiza(4,4,v);
    }
    if(v.size()==7)
    {
        return analiza(1,6,v);
    }
}

