-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogic.cpp
More file actions
83 lines (75 loc) · 2.36 KB
/
logic.cpp
File metadata and controls
83 lines (75 loc) · 2.36 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
#include "logic.h"
namespace BLOCK
{
Block::Block(std::string seed):main(4,std::vector<int>(18)),now(0)
{
for (int s = 0; s < 4; s++)
{
for (int i = 0; i < 18; i++)
{
main[s][i]=(int)(seed[18*s+i]-'0');
}
}
}
std::vector<int> & Block::get()
{
int randomNumber = 0;
std::srand(std::time(0)+now*100000);
randomNumber = rand()%4;
if (now == randomNumber)
{
std::srand(std::time(0)+212131);
randomNumber = rand()%4;
}
now = randomNumber;
return main[now];
}
std::vector<int> & Block::operator++()
{
now = (now + 1)%4;
return main[now];
}
std::vector<int> & Block::operator--()
{
now = (now - 1)%4;
now = (now >= 0)?now:-now;
return main[now];
}
/*
class BLOCKS
{
public:
std::vector<Block> store;
BLOCKS();
std::vector<int> & get();
};
*/
BLOCKS::BLOCKS():seed(1212212)
{
using std::string;
string BlueRicky = "000000001000111032000011001000100023000000001110001032000001000100110023";
store.emplace_back(BlueRicky);
string OrangeRicky = "000000000010111032000010001000110023000000001110100032000011000100010023";
store.emplace_back(OrangeRicky);
string Smashboy = "000000001100110022000000001100110022000000001100110022000000001100110022";
store.emplace_back(Smashboy);
string Hero = "000000000000111141100010001000100014000000000000111141100010001000100014";
store.emplace_back(Hero);
string Teewee = "000000000100111032000010001100100023000000001110010032000001001100010023";
store.emplace_back(Teewee);
string ClevelandZ = "000000001100011032000001001100100023000000001100011032000001001100100023";
store.emplace_back(ClevelandZ);
string RhodeIslandZ = "000000000110110032000010001100010023000000000110110032000010001100010023";
store.emplace_back(RhodeIslandZ);
}
Block & BLOCKS::get()
{
int randomNumber = 0;
std::srand(std::time(nullptr)+seed);
randomNumber = rand();
seed = randomNumber;
std::srand(randomNumber%7+seed);
randomNumber = rand();
return store[randomNumber%7];
}
}