#include "vision.h"

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

int getMove1d(std::vector<int> v)
{
  if(v.size() == 3) {
    for(int i = 0; i < v.size(); ++i) if(v[i] != 1) return i;
    return 0;
  }
  if(v.size() == 5) {
    if(v.front() == 3) return 0;
    return v.size()-1;
  }
  if(v[1] == 2) return v.size()-1;
  return 0;
}

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

std::pair<int, int> getMove2d(std::vector<std::vector<int>> v)
{
  if(v.size() == 3) {
    for(int i = 0; i < 3; ++i) for(int j = 0; j < 3; ++j) if(v[i][j] != 1) return {i, j};
    return {2, 2};
  }
  if(v.size() == 5) {
    for(int i = 1; i < 4; ++i) for(int j = 1; j < 4; ++j) if(v[i][j] == 3) return {i, j};
    for(int i = 0; i < 5; ++i) for(int j = 0; j < 5; ++j) if(v[i][j] == 2 && i != 2) return {i, j};
  }
  if(v[2][2] == 2) return {6, 6};
  if(v[4][4] == 2) return {0, 0};
  if(v[2][4] == 2) return {6, 0};
  return {0, 6};
}
