-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSolverC.h
More file actions
50 lines (37 loc) · 1.22 KB
/
SolverC.h
File metadata and controls
50 lines (37 loc) · 1.22 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
/*
* SolverC.h
*
* Created on: Apr 28, 2014
* Author: igor
*/
#ifndef SOLVERC_H_
#define SOLVERC_H_
#include "Solution.h"
#include "CandidatesCalculator.h"
#include "CandidatesT.h"
#include <iostream>
int CudaSolve(CandidatesOffsets candidatesOffsets, CandidatesMask candidatesMask, SituationT (&solutions)[MaxSolutions]);
class SolverC {
public:
std::list<Solution> solutions;
SolverC(const std::shared_ptr<const Board>& board) {
auto c = CandidatesCalculator(board).GetCandidates();
auto gridSize(board->GetSize());
Coord pos(Ints(gridSize.size()));
std::shared_ptr<CandidatesT::Type> candidatesPerPiece = std::make_shared<CandidatesT::Type>();
Enumerate(pos, gridSize, [&] {
candidatesPerPiece->push_back((*c)[pos]);
return true;
});
candidatesT = std::make_shared<CandidatesT>(candidatesPerPiece);
}
void Solve() {
SituationT ss[MaxSolutions];
const int n = CudaSolve(candidatesT->candidatesOffsets, candidatesT->candidatesMask, ss);
for (int i = 0; i < n; i++)
solutions.push_back(candidatesT->Convert(ss[i]));
}
private:
std::shared_ptr<const CandidatesT> candidatesT;
};
#endif /* SOLVERC_H_ */