-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathkamenNuzky.cpp
129 lines (103 loc) · 2.96 KB
/
kamenNuzky.cpp
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <time.h>
using namespace std;
#if defined(__WIN32__) || defined(_WIN32) || defined(WIN32) || defined(__WINDOWS__) || defined(__TOS_WIN__)
#include <windows.h>
inline void delay( unsigned long ms )
{
Sleep( ms );
}
#else /* presume POSIX */
#include <unistd.h>
inline void delay( unsigned long ms )
{
usleep( ms * 1000 );
}
#endif
void vAI (char choice) {
cout << "Pocitac te porazil, zahral ";
if (choice == 'k')
cout << " papir";
if (choice == 'n')
cout << " kamen";
if (choice == 'p')
cout << " nuzky";
cout << ". Priste to uz vyjde ;)" << endl;
}
int main() {
srand (time(NULL));
int AI;
int player;
string k;
char choice;
cout << "Hra kamen, nuzky, papir, ted." << endl;
cout << "Napis 'k' pro kamen, 'n' pro nuzky, 'p' pro papir a zmackni 'ENTER'" << endl;
while (true) {
cin >> choice;
cout <<
" .--,-``-. " << endl <<
" / / '. " << endl <<
" / ../ ; " << endl <<
" \\ ``\\ .`- ' " << endl <<
" \\___\\/ \\ : " << endl <<
" \\ : | " << endl <<
" / / / " << endl <<
" \\ \\ \\ " << endl <<
" ___ / : | " << endl <<
" / /\\ / : " << endl <<
" / ,,/ ',- . " << endl <<
" \\ ''\\ ; " << endl <<
" \\ \\ .' " << endl <<
" `--`-,,-' " << endl << endl;
delay (700);
cout <<
" ,----, " << endl <<
" .' .' \\ " << endl <<
" ,----,' | " << endl <<
" | : . ; " << endl <<
" ; |.' / " << endl <<
" `----'/ ; " << endl <<
" / ; / " << endl <<
" ; / /-, " << endl <<
" / / /.`| " << endl <<
" ./__; : " << endl <<
" | : .' " << endl <<
" ; | .' " << endl <<
" `---' " << endl << endl;
delay (700);
cout <<
" ,---, " << endl <<
" ,`--.' | " << endl <<
" / / : " << endl <<
" : |.' ' " << endl <<
" `----': | " << endl <<
" ' ' ; " << endl <<
" | | | " << endl <<
" ' : ; " << endl <<
" | | ' " << endl <<
" ' : | " << endl <<
" ; |.' " << endl <<
" '---' " << endl << endl;
delay (700);
AI = rand()%3;
if (choice == 'k')
player = 0;
if (choice == 'n')
player = 1;
if (choice == 'p')
player = 2;
if (player == AI)
cout << "Remiza... " << endl;
else if (player == 0 and AI == 2)
vAI(choice);
else if (player < AI)
vAI(choice);
else
cout << "Porazil jsi pocitac!" << endl;
cout << "Pro dalsi hru napis 'k' pro kamen, 'n' pro nuzky, 'p' pro papir a zmackni 'ENTER'" << endl;
}
return 0;
}