{"size": 658, "ext": "js", "max_stars_repo_path": "src/maths.js", "max_stars_repo_name": "pauldijou/boardgame", "max_stars_repo_stars_event_min_datetime": "2018-03-24T21:32:00.000Z", "max_stars_repo_stars_event_max_datetime": "2018-04-10T12:25:30.000Z", "max_issues_repo_path": "src/maths.js", "max_issues_repo_name": "pauldijou/boardgame", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/maths.js", "max_forks_repo_name": "pauldijou/boardgame", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 2, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 21.9333333333, "max_line_length": 64, "alphanum_fraction": 0.4407294833}
export function neighborsSquare2D(x, y) {
  return [
    {x: x + 1, y: y    },
    {x: x - 1, y: y    },
    {x: x,     y: y - 1},
    {x: x,     y: y + 1}
  ];
}

export function neighborsHegaxon2D(x, y) {
  return [
    {x: x + 1, y: y    },
    {x: x + 1, y: y - 1},
    {x: x,     y: y - 1},
    {x: x - 1, y: y    },
    {x: x - 1, y: y + 1},
    {x: x,     y: y + 1}
  ];
}

export function distanceSquare2D(x1, y1, x2, y2) {
  return Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));
}

export function distanceHexagon2D(x1, y1, x2, y2) {
  return (Math.abs(x1 - x2)
          + Math.abs(x1 + y1 - x2 - y2)
          + Math.abs(y1 - y2)) / 2;
}
