mirror of
https://github.com/ProgramSnail/snake_2024.git
synced 2025-12-23 22:58:44 +00:00
functional bots, small refactoring, readme edit
This commit is contained in:
parent
5299e89633
commit
7e67a3bd30
13 changed files with 179 additions and 91 deletions
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
|
||||
template <typename T> struct Vec {
|
||||
T x = {};
|
||||
|
|
@ -78,7 +79,7 @@ template <typename T> struct Vec {
|
|||
|
||||
//
|
||||
|
||||
int len_sq() const { return dot(*this, *this); }
|
||||
T len_sq() const { return dot(*this, *this); }
|
||||
|
||||
double len() const { return std::sqrt(len_sq()); }
|
||||
|
||||
|
|
@ -86,14 +87,14 @@ template <typename T> struct Vec {
|
|||
|
||||
//
|
||||
|
||||
int static dot(Vec left, Vec right) {
|
||||
T static dot(Vec left, Vec right) {
|
||||
return left.x * right.x + left.y * right.y;
|
||||
}
|
||||
|
||||
int static cross(Vec left, Vec right) {
|
||||
T static cross(Vec left, Vec right) {
|
||||
return left.x * right.y - left.y * right.x;
|
||||
}
|
||||
};
|
||||
|
||||
using Veci = Vec<int>;
|
||||
using Veci = Vec<int64_t>;
|
||||
using Vecf = Vec<double>;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue