#include<bits/stdc++.h>
#include "vision.h"

std::vector<int> getVisionPattern1d() {
    return {1, 1, 2, 3};
}
int getMove1d(std::vector<int> v) {
    int mid = v.size() / 2;
    if (v[mid] == 2) {
        if (v[mid + 1] == 3) return mid + 1;
        else return mid - 1;
    }
    if (v[mid] == 3) {
        if (v[mid + 1] == 1) return mid + 1;
        else return mid - 1;
    }
    if (v[mid] == 1) {
        if (v[mid + 1] == 2) return mid + 1;
        if (v[mid - 1] == 2) return mid - 1;
        if (v[mid + 1] == 3) return mid - 1;
        if (v[mid - 1] == 3) return mid + 1;
    }
    return -1;
}
std::vector<std::vector<int>> getVisionPattern2d() {
    return {{1, 2}, {3, 4}};
}
std::pair<int, int> getMove2d(std::vector<std::vector<int>> v) {
    int mid = v.size() / 2;
    int next;
    if (v[mid][mid] == 1) next = 2;
    else if (v[mid][mid] == 2) next = 1;
    else if (v[mid][mid] == 3) next = 4;
    else next = 3;
    for (auto [dx, dy] : std::vector<std::pair<int, int>>{{0, 1}, {0, -1}, {1, 0}, {-1, 0}}) {
        if (v[mid + dx][mid + dy] == next) {
            return {mid + dx, mid + dy};
        }
    }
    return {-1, -1};
}