Initial commit, some logic added

This commit is contained in:
2026-05-23 11:50:32 +03:00
commit 96eefbe181
9 changed files with 370 additions and 0 deletions
+45
View File
@@ -0,0 +1,45 @@
#pragma once
#include "tilePosition.h"
#include "line.h"
#include "types.h"
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <random>
class Field {
private:
std::mt19937 mt;
Score score = 0;
size_t FieldSize = 4;
std::vector<Line> field;
std::vector<Tile> processLine(const std::vector<Tile> &sourceLine, Score &score);
Line getRow(size_t rowIndex) const;
std::vector<Tile> getColumn(size_t columnIndex) const;
void setRow(size_t rowIndex, const std::vector<Tile> &line);
void setColumn(size_t columnIndex, const std::vector<Tile> &line);
void reset();
void setSize(size_t size);
public:
Field(size_t fieldSize);
bool canMove() const;
bool moveUp();
bool moveDown();
bool moveLeft();
bool moveRight();
std::vector<Position> getEmptyTiles() const;
bool spawnTile(const std::vector<Position> &empty);
void debug() const;
};
+13
View File
@@ -0,0 +1,13 @@
#include "types.h"
#include <vector>
struct Line {
std::vector<Tile> line;
Score score;
explicit Line();
Line(size_t length);
void process();
};
+9
View File
@@ -0,0 +1,9 @@
#pragma once
struct Position {
int x;
int y;
Position() : x(0), y(0) {}
Position(int x, int y) : x(x), y(y) {}
};
+4
View File
@@ -0,0 +1,4 @@
#pragma once
using Tile = unsigned long long int;
using Score = unsigned long long int;