#include "vision.h"

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

int getMove1d(std::vector<int> v) {
    if (v.size() == 3) return v[2] != 1 ? 2 : 0;
    if (v.size() == 5) return v[4] == 3 ? 4 : 0;
    if (v.size() == 7) return v[1] == 2 ? 6 : 0;
    return 0;
}

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

std::pair<int, int> getMove2d(std::vector<std::vector<int>> v) {
    if (v.size() == 7) {
        if (v[2][2] == 2) return {6, 6};
        if (v[4][2] == 2) return {0, 6};
        if (v[2][4] == 2) return {6, 0};
        if (v[4][4] == 2) return {0, 0};
    }
    int bx = 0, by = 0;
    for (int x = 0; x < v.size(); x++) {
        for (int y = 0; y < v[x].size(); y++) {
            if (v[x][y] > v[bx][by]) bx = x, by = y;
        }
    }
    return {bx, by};
}
