-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDanceGenerator.cpp
More file actions
88 lines (72 loc) · 1.97 KB
/
DanceGenerator.cpp
File metadata and controls
88 lines (72 loc) · 1.97 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*
* DanceGenerator.h
* Written by: Mark Koh
* DARwIn-OP Dance Synthesis Project
* 06/04/2013
*
* Description: This object takes a ssequenceTable and uses it to generate dances
* based as a state-based machine.
*
*/
#include "DanceGenerator.h"
using namespace std;
//-------------------------------------------------
//-------------- Constructors ---------------------
//-------------------------------------------------
DanceGenerator::DanceGenerator(SequenceTable table) {
//Initialize anything that we need to initialize here
_table = table;
init();
}
//-------------------------------------------------
//-------------- Destructor ---------------------
//-------------------------------------------------
DanceGenerator::~DanceGenerator() {
}
//-------------------------------------------------
//-------------- Inspectors - ---------------------
//-------------------------------------------------
void DanceGenerator::init(){
int pos = _table.getRandomBase();
_currentPos = pos;
_atBase = true;
}
int DanceGenerator::currentPos(){
return _currentPos;
}
//-------------------------------------------------
//-------------- Mutators -------------------------
//-------------------------------------------------
int DanceGenerator::next() {
int pos;
if(_atBase){
//We're at a base, switch to a move
pos = (int)_table.getRandomMove();
_atBase = false;
}
else {
//We're at a move, get a random sequential move
pos = _table.getRandomNext(_currentPos);
if (pos == -1){
//We're at the end of the line, switch back to a base position
pos = _table.getRandomBase();
_atBase = true;
}
}
//Update the current move
_currentPos = pos;
return _currentPos;
}
void DanceGenerator::setPos(int pos){
if (_table.isMove(pos)){
_currentPos = pos;
_atBase = false;
}
else if (_table.isBase(pos)){
_currentPos = pos;
_atBase = true;
}
}
bool DanceGenerator::atBase() const{
return _atBase;
}