Initial commit, some logic added
This commit is contained in:
Executable
+45
@@ -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;
|
||||
};
|
||||
@@ -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();
|
||||
};
|
||||
Executable
+9
@@ -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) {}
|
||||
};
|
||||
@@ -0,0 +1,4 @@
|
||||
#pragma once
|
||||
|
||||
using Tile = unsigned long long int;
|
||||
using Score = unsigned long long int;
|
||||
Reference in New Issue
Block a user