-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtoolKit.h
More file actions
69 lines (57 loc) · 1.54 KB
/
Copy pathtoolKit.h
File metadata and controls
69 lines (57 loc) · 1.54 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
* toolKit.h
*
* Created on: 16 ���� 2015
* Author: Lior
*/
#ifndef TOOLKIT_H_
#define TOOLKIT_H_
#include <bitset>
#include "puzgen.h"
#define SIZE_OF_BITSET 8
#define DECISION_BIT 7
#define ARR_SIZE 6
class PartialSolution
{
private:
std::bitset<SIZE_OF_BITSET> solArr[ARR_SIZE][ARR_SIZE];
public:
PartialSolution();
PartialSolution(PartialSolution *part);
bool isCellDecided(int row, int col);
bool isOptionDecided(int row, int option);
void setDecisionBit(int row, int col,bool trueFalse);
bool allDecided();
bool isOneOptionLeftForCell(int row,int col);
int getFirstCellForOption(int row, int option);
int getFirstOptionForCell(int row, int col);
int numOfCellsForOption(int row, int option);
int NumOFOptionsForCell(int row,int col);
bool setOptionForCell(int row, int col, int option, bool value);
bool getOptionForCell(int row, int col, int option);
void chooseOptionForCell(int row, int col, int option, bool useForwardChecking);
};
class Constraint
{
private:
std::vector<int> rows;
std::vector<int> things;
std::vector<std::vector<int> > permutations;
public:
Constraint(Rule *rule);
Constraint(int row);
void print();
bool isVarPresent(int row,int thing);
int checkNumOfVars();
bool checkConstraintHoldsForSol(PartialSolution* sol);
};
class AllConstraints
{
private:
std::vector<Constraint> all;
public:
AllConstraints(Rules rules);
std::vector<Constraint> returnReleventConstraints(int row,int thing);
bool isSolValid(PartialSolution *sol);
};
#endif /* TOOLKIT_H_ */