#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}, {2, 3, 1}, {3, 1, 2}};
}

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