#include "vision.h"
#include<vector>
using namespace std;
std::vector<int> getVisionPattern1d()
{
    return {1, 1, 2, 2, 1, 2};

}

int getMove1d(std::vector<int> v)
{
    vector<int> a = {1, 2, 2, 1, 2}, b = {2, 1, 2, 1, 1}, c = {1, 1, 2, 2, 1};
    if (v.size() == 3) {
        if (v[0] == 2) {
            return 0;
        }
        return 2;
    }
    if (v == a || v == b || v == c) {
        return 4;
    }
    return 0;
}

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

std::pair<int, int> getMove2d(std::vector<std::vector<int>> v)
{
    if (v.size() != 9) {
        for (int i = 0; i < v.size(); i++) {
            for (int j = 0; j < v.size(); j++) {
                if (v[i][j] == 4) {
                    return {i, j};
                }
            }
        }
        throw(0);
    }
    long long x, y;
    if (v[3][4] == 3) {
        x = 0;
    } else {
        x = 8;
    }
    if (v[4][3] == 3) {
        y = 8;
    }  else {
        y = 0;
    }
    x = 8 - x; y = 8 - y;
    if (v[x][y] != 4) {
        throw(0);
    }
    return {x, y};
}
