-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPuzzle.h
58 lines (44 loc) · 1.05 KB
/
Puzzle.h
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <queue>
#include <climits>
#include <iostream>
#include <cassert>
class pCell {
public:
pCell(int _val = 1)
:val (_val)
{}
int val;
std::vector<int> succ;
std::vector<int> pred;
int gVal;
bool uniquePath;
bool reachable;
bool reaching;
};
class Puzzle{
public:
Puzzle(int nRows, int nColumns, int minVal, int maxVal);
int GetValue();
bool HasSolution();
Puzzle GetRandomSuccessor();
void GetAllSuccessors(std::vector<Puzzle> & successors);
void Print(bool printStatistics = true);
private:
void Randomize();
void GenerateEdges();
void AddEdge(int r1, int c1, int r2, int c2);
void SetCellValue(int cell, int value);
void Evaluate();
void ComputeValue();
void ForwardSearch();
void BackwardSearch();
std::vector<pCell> cells;
int nRows, nColumns, minVal, maxVal, pSize;
bool hasSolution, hasUniqueSolution;
bool evaluated;
int solutionLength, nWhiteHoles, nBlackHoles, nForcedForwardMoves, nForcedBackwardMoves, nReachableCells, nReachingCells;
int value;
};