#include "vision.h"
#include <iostream>
using namespace std;

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

int getMove1d(std::vector<int> v)
{
    int idx = v.size() / 2;
    if (v[idx] == 3) {
        if (v[0] == 2)
            return v.size() - 1;
        else
            return 0;
    } else if (v[idx] == 2) {
        return idx + 1;
    } else if (v[idx] == 1) {
        if (v[idx - 1] == 2)
            return idx + 1;
        else if (v[idx + 1] == 2)
            return idx - 1;
        else if (v[idx - 1] == 3)
            return idx - 1;
        else
            return idx + 1;
    }
}

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

std::pair<int, int> getMove2d(std::vector<std::vector<int>> v)
{   
    pair <int, int> ans = {0, 0};
    for (int y = 2; y < v.size() - 2; y++)
        for (int x = 2; x < v[y].size() - 2; x++)
            if (v[y][x] == 2) {
                if (v[y][x + 2] == 3)
                    ans.second = x + 2;
                else
                    ans.second = x - 2;
            }
    return ans;
}
