-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBot.h
More file actions
43 lines (34 loc) · 1.44 KB
/
Bot.h
File metadata and controls
43 lines (34 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#ifndef BOT_H
#define BOT_H
#include "Board.h"
#include "Tetromino.h"
struct Move {
int x;
int rotations;
int score;
Move() : x(0), rotations(0), score(-999999) {}
Move(int x_, int rotations_, int score_) : x(x_), rotations(rotations_), score(score_) {}
};
class Bot {
public:
Bot();
// Find the best move for the current piece on the given board
Move findBestMove(const Board& board, const Tetromino& piece);
Move findBestMoveWithLookahead(const Board& board, const Tetromino& current, const Tetromino& next);
// Heuristic evaluation functions (public for testing)
int countHoles(const Board& board) const;
int getAggregateHeight(const Board& board) const;
int getBumpiness(const Board& board) const;
int getMaxHeight(const Board& board) const;
int getRowTransitions(const Board& board) const;
int getColTransitions(const Board& board) const;
int getWellDepth(const Board& board) const;
int getColumnHeight(const Board& board, int x) const;
private:
// Simulate placing a piece and evaluate the resulting board
int evaluateBoard(const Board& board, const Tetromino& piece, int x, int rotations);
int evaluateBoardWithLookahead(const Board& board, const Tetromino& current, int x, int rot, const Tetromino& next);
// Create a copy of the board with the piece placed
Board simulatePlacement(Board board, const Tetromino& piece, int x, int rotations);
};
#endif // BOT_H