#include "vision.h"
#include<bits/stdc++.h>
using namespace std;

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

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

std::vector<std::vector<int>> getVisionPattern2d()
{
    vector<vector<int>> ans(0);
    vector<int> wut(3);
    ans.push_back(wut);
    ans.push_back(wut);
    ans.push_back(wut);
    ans[0][0] = 1;
    ans[0][1] = 1;
    ans[0][2] = 1;
    ans[1][0] = 1;
    ans[1][1] = 2;
    ans[1][2] = 2;
    ans[2][0] = 1;
    ans[2][1] = 2;
    ans[2][2] = 1;
    return ans;
}

std::pair<int, int> getMove2d(std::vector<std::vector<int>> v)
{
    if(v.size() == 3) {
        for(int i = 0; i < 3; i++) {
            for(int j = 0; j < 3; j++) {
                if(v[i][j] == 2) {
                    return {i,j};
                }
            }
        }
    }
    vector<pair<int,int>> wut(0);
    if(v[1][2] == 2) {
        wut.push_back({-1,0});
    }
    if(v[2][1] == 2) {
        wut.push_back({0,-1});
    }
    if(v[3][2] == 2) {
        wut.push_back({1,0});
    }
    if(v[2][3] == 2) {
        wut.push_back({0,1});
    }
    if(wut.size() == 2) {
        return {2+wut[0].first,2+wut[0].second};
    }
    int dx = wut[0].first,dy = wut[0].second;
    int x = 2-2*dx,y = 2-2*dy;
    if(dy == 0) {
        if(v[x][y-1] == 2) {
            return {x,y-1};
        }
        else {
            return {x,y+1};
        }
    }
    else {
        if(v[x-1][y] == 2) {
            return {x-1,y};
        }
        else {
            return {x+1,y};
        }
    }
}
