This repository has been archived by the owner on May 5, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
QState.h
68 lines (55 loc) · 1.68 KB
/
QState.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
59
60
61
62
63
64
65
66
67
68
//--------------------------------------------------------------------------
// File: QState.h
//
// Created by: Joel S. McCance
// Creation date: Fri Feb 25 11:24:34 2011
// Last modified: Tue Mar 1 11:55:27 2011
//--------------------------------------------------------------------------
#ifndef __QState_h__
#define __QState_h__
#include <vector>
class QState {
public:
QState( );
/*
Generates a board of size zero.
Used when you want to create a QState but don't need to
initialize it yet.
*/
QState(int size);
/*
Generates a size x size QState with a random start state.
*/
QState(QState& parent, unsigned int row, unsigned int col);
/*
Generates a new QState with the same state as parent, but
moving the queen in the designated row to the designated
column.
*/
int getScore( );
void generateSuccessors(std::vector<QState>& successors);
/*
Generate a list of successors of self and store it in the
provide vector.
NOTE: Would like to accept any container that supports
push_back( ). Refer to
*/
void printBoard( );
/*
Pretty-prints the state. E.g., this size-4 board
. Q . .
Q . . .
. . Q .
. . . Q
*/
private:
static bool _initialized;
std::vector<unsigned int> _state;
unsigned int _size;
unsigned int _score;
int countAttacks( );
/*
Returns the number of attacking pairs on this board.
*/
};
#endif