-
Notifications
You must be signed in to change notification settings - Fork 0
/
Labirinth.h
584 lines (497 loc) · 24 KB
/
Labirinth.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
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
#include<iostream>
#include<string>
#include<fstream>
#include<windows.h>
#include<conio.h>
#include<time.h>
using namespace std;
ifstream f1("easy.txt");
ifstream f2("medium.txt");
ifstream f3("hard.txt");
int line_type[100][100];
int x ;
#define key_up 72
#define key_down 80
#define key_left 75
#define key_rigth 77
HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
COORD CursorPosition;
//finds if there is an vertical line at the poz a[i][j]
bool ver_line(int a[100][100], int i, int j, int line_type[100][100])
{//if (line_type[i][j] == 2)return false;
if (i % 2 == 0 && j % 2 == 0)
if (a[i][j] == 1 && a[i][j + 1] == 1 && a[i + 1][j] == 1 && a[i + 1][j + 1] == 1)
if (a[i - 1][j] == 1 && a[i - 1][j + 1] == 1 && a[i + 2][j] == 1 && a[i + 2][j + 1] == 1) return true;
else return false;
if (j % 2 == 0)
// if (line_type[i][j] == 1 || line_type[i][j] == 3)
if (a[i][j] == 1 && a[i][j + 1] == 1 && a[i + 1][j] == 1 && a[i + 1][j + 1] == 1) return true;
return false;
}
//find if there is an orizontal line at the poz a[i][j]
bool or_line(int a[100][100], int i, int j, int line_type[100][100])
{//if (line_type[i][j] == 1)return false;
if (i % 2 == 0 && j % 2 == 0)
if (a[i][j] == 1 && a[i][j + 1] == 1 && a[i + 1][j] == 1 && a[i + 1][j + 1] == 1)
if (a[i][j - 1] == 1 && a[i + 1][j - 1] == 1 && a[i][j + 2] == 1 && a[i + 1][j + 2] == 1) return false;
if (i % 2 == 0 && j % 2 == 0)
if (ver_line(a, i, j, line_type))return false;
if (i % 2 == 0)
// if (line_type[i][j] == 2 || line_type[i][j] == 3)
if (a[i][j] == 1 && a[i][j + 1] == 1 && a[i + 1][j] == 1 && a[i + 1][j + 1] == 1) return true;
return false;
}
//find if there is a T shape
bool up_T(int a[100][100], int i, int j, int line_type[100][100])
{
if (or_line(a, i, j - 1, line_type) && or_line(a, i, j + 1, line_type) && ver_line(a, i + 1, j, line_type)) return true;
return false;
}
//find if there is an upside down T shape
bool down_T(int a[100][100], int i, int j, int line_type[100][100])
{
if (or_line(a, i, j - 1, line_type) && or_line(a, i, j + 1, line_type) && ver_line(a, i - 1, j, line_type)) return true;
return false;
}
//find if there is an left T shape
bool left_T(int a[100][100], int i, int j, int line_type[100][100])
{
if (ver_line(a, i, j, line_type))
if (ver_line(a, i - 1, j, line_type) && ver_line(a, i + 1, j, line_type) && or_line(a, i, j - 1, line_type)) return true;
return false;
}
//find if there is a right T shape
bool right_T(int a[100][100], int i, int j, int line_type[100][100])
{
if (ver_line(a, i, j, line_type))
if (ver_line(a, i - 1, j, line_type) && ver_line(a, i + 1, j, line_type) && or_line(a, i, j + 1, line_type)) return true;
return false;
}
//find if there is a + shape
bool plus_shape(int a[100][100], int i, int j, int line_type[100][100])
{
if (or_line(a, i, j - 1, line_type) && or_line(a, i, j + 1, line_type) && ver_line(a, i - 1, j, line_type) && ver_line(a, i + 1, j, line_type))return true;
return false;
}
//corner down-left
bool l_down(int a[100][100], int i, int j, int line_type[100][100])
{
if (a[i][j] == 1 && a[i + 1][j] == 0 && or_line(a, i, j + 1, line_type) && ver_line(a, i - 1, j, line_type)) return true;
return false;
}
//corner up-right
bool r_up(int a[100][100], int i, int j, int line_type[100][100])
{
if (a[i][j] == 0 && or_line(a, i, j - 2, line_type) && ver_line(a, i + 1, j - 1, line_type)) return true;
return false;
}
//corner down-right
bool r_down(int a[100][100], int i, int j, int line_type[100][100])
{
if (a[i][j] == 1 && a[i + 1][j] == 0 && or_line(a, i, j - 2, line_type) && ver_line(a, i - 1, j - 1, line_type)) return true;
return false;
}
//corner up-left
bool l_up(int a[100][100], int i, int j, int line_type[100][100])
{
if (a[i][j] == 0 && or_line(a, i, j + 1, line_type) && ver_line(a, i + 1, j, line_type)) return true;
return false;
}
void Labirinth_generator(int a[100][100], int width, int length, int poz_i, int poz_j, int line_type[100][100])
{
int i, j;
for (i = 0; i <= width; i++)
for (j = 0; j <= length; j++)
{ //corners
if (i == 0 && j == 0)cout << "\xC9";
if (i == 0 && j == length)cout << "\xBB" << endl;
if (i == width&&j == 0)cout << "\xC8";
if (i == width&&j == length)cout << "\xBC" << endl;
//border up
if (i == 0 && j != 0 && j != length && a[1][j] == 1 && a[1][j + 1] == 1 && j % 2 == 0) cout << "\xCD\xCB";
else if (i == 0 && j == length - 1)cout << "\xCD";
else if (i == 0 && j != 0 && j != length)cout << "\xCD\xCD";
//border down
if (i == width && j != 0 && j != length&&a[width - 1][j] == 1 && a[width - 1][j + 1] == 1 && j % 2 == 0)cout << "\xCD\xCA";
else if (i == width && j == length - 1)cout << " ";
else if (i == width && j == length - 2)cout << " ";
else if (i == width && j == length - 3)cout << "\xCD ";
else if (i == width && j != 0 && j != length)cout << "\xCD\xCD";
//border left
if (j == 0 && i != 0 && i != width&&i != width - 1 && a[i][1] == 1 && a[i + 1][1] == 1 && i % 2 == 0)cout << "\xCC";
else if (j == 0 && i != 0 && i != width &&i != width - 1)cout << "\xBA";
//border right
if (j == length && i != 0 && i != width &&i != width - 1 && a[i][length - 1] == 1 && a[i + 1][length - 1] == 1 && i % 2 == 0)cout << "\xB9" << endl;
else if (j == length &&i != 0 && i != width && i != width - 1)cout << "\xBA" << endl;
//inside corners
if (l_down(a, i, j, line_type)) cout << "\xC8";
if (r_up(a, i, j, line_type))cout << "\xBB";
if (r_down(a, i, j, line_type))cout << "\xBC";
if (l_up(a, i, j, line_type))cout << "\xC9";
//spaces
if (j % 2 == 1 && i != 0 && i != width - 1 && i != width - 1)
{
if (a[i][j] == 0 && ver_line(a, i - 1, j + 1, line_type) && a[i + 1][j + 1] == 0 && l_down(a, i, j + 1, line_type) == 0 && a[i][j + 3] != 0 && i == poz_i&&j == poz_j) cout << " \x99 ";//4
else if (a[i][j] == 0 && ver_line(a, i - 1, j + 1, line_type) && l_down(a, i, j + 1, line_type) == 0 && a[i + 1][j + 1] == 0 && a[i][j + 3] != 0)cout << " ";//4
else if (a[i][j] == 0 && ver_line(a, i - 1, j + 1, line_type) && a[i + 1][j + 1] == 0 && l_down(a, i, j + 1, line_type) == 0 && i == poz_i&&j == poz_j) cout << " \x99 ";//4
else if (a[i][j] == 0 && ver_line(a, i - 1, j + 1, line_type) && a[i + 1][j + 1] == 0 && l_down(a, i, j + 1, line_type) == 0 && l_up(a, i, j + 3, line_type) == 0)cout << " ";//4
else if (a[i][j] == 0 && ver_line(a, i - 1, j + 1, line_type) && i == poz_i&&j == poz_j) cout << " \x99 ";//3
else if (a[i][j] == 0 && ver_line(a, i - 1, j + 1, line_type))cout << " ";//3
else if (a[i][j] == 0 && ver_line(a, i, j + 1, line_type) && i == poz_i&&j == poz_j) cout << " \x99 ";//3
else if (a[i][j] == 0 && ver_line(a, i, j + 1, line_type))cout << " ";//3
else if (a[i][j] == 0 && l_down(a, i, j + 1, line_type) && i == poz_i&&j == poz_j)cout << " \x99 ";//3
else if (a[i][j] == 0 && l_down(a, i, j + 1, line_type))cout << " ";//3
else if (a[i][j] == 0 && l_up(a, i, j + 1, line_type) && i == poz_i&&j == poz_j)cout << " \x99 ";//3
else if (a[i][j] == 0 && l_up(a, i, j + 1, line_type))cout << " ";//3
// else if (or_line(a,i,j-2)&&or_line(a,i,j+2)&&a[i][j] == 0 && a[i][j + 1] == 0 && j != length - 2 && i == poz_i&&j == poz_j)cout << " \x99 ";//5
// else if (or_line(a, i, j - 2) && or_line(a, i, j + 2) && a[i][j] == 0 && a[i][j + 1] == 0 && j != length - 2)cout << " ";//5
else if (a[i][j] == 0 && a[i][j + 1] == 0 && j != length - 2 && i == poz_i&&j == poz_j)cout << " \x99 ";//4
else if (a[i][j] == 0 && a[i][j + 1] == 0 && j != length - 2)cout << " ";//4
else if (a[i][j] == 0 && a[i][j + 1] == 0 && j == length - 2 && i == poz_i&&j == poz_j)cout << " \x99 ";//3
else if (a[i][j] == 0 && a[i][j + 1] == 0 && j == length - 2)cout << " ";//3
else if (a[i][j] == 0 && ver_line(a, i, j + 1, line_type) && i == poz_i&&j == poz_j)cout << " \x99 ";//3
else if (a[i][j] == 0 && ver_line(a, i, j + 1, line_type))cout << " ";//3
if (a[i][j] == 1 && ver_line(a, i, j - 1, line_type) && or_line(a, i, j, line_type) == 0 && j != length - 2 && ver_line(a, i, j + 1, line_type) && i == poz_i&&j == poz_j)cout << " \x99 ";//3
else if (a[i][j] == 1 && ver_line(a, i, j - 1, line_type) && or_line(a, i, j, line_type) == 0 && j != length - 2 && ver_line(a, i, j + 1, line_type))cout << " ";//3
else if (a[i][j] == 1 && r_down(a, i, j, line_type) && a[i][j + 1] == 0 && a[i][j + 2] == 0 && i == poz_i&&j == poz_j) cout << " \x99 ";//4
else if (a[i][j] == 1 && r_down(a, i, j, line_type) && a[i][j + 1] == 0 && a[i][j + 2] == 0) cout << " ";//4
else if (a[i][j] == 1 && r_down(a, i, j, line_type) && a[i][j + 1] == 0 && or_line(a, i, j + 2, line_type) && l_up(a, i, j + 1, line_type) == 0 && i == poz_i&&j == poz_j) cout << " \x99 ";//4
else if (a[i][j] == 1 && r_down(a, i, j, line_type) && a[i][j + 1] == 0 && l_up(a, i, j + 1, line_type) == 0 && or_line(a, i, j + 2, line_type)) cout << " ";//4
else if (a[i][j] == 1 && l_down(a, i, j + 1, line_type) && i == poz_i&&j == poz_j)cout << " \x99 ";//3
else if (a[i][j] == 1 && l_down(a, i, j + 1, line_type))cout << " ";//3
else if (a[i][j] == 1 && l_up(a, i, j + 1, line_type) && ver_line(a, i, j - 1, line_type) && i == poz_i&&j == poz_j)cout << " \x99 ";//3
else if (a[i][j] == 1 && l_up(a, i, j + 1, line_type) && ver_line(a, i, j - 1, line_type))cout << " ";//3
else if (a[i][j] == 1 && ver_line(a, i, j - 1, line_type) && or_line(a, i, j, line_type) == 0 && j != length - 2 && i == poz_i&&j == poz_j) cout << " \x99 ";//4
else if (a[i][j] == 1 && ver_line(a, i, j - 1, line_type) && or_line(a, i, j, line_type) == 0 && j != length - 2) cout << " ";//4
else if (a[i][j] == 1 && ver_line(a, i, j - 1, line_type) && or_line(a, i, j, line_type) == 0 && j == length - 2 && i == poz_i&&j == poz_j)cout << " \x99 "; //3
else if (a[i][j] == 1 && ver_line(a, i, j - 1, line_type) && or_line(a, i, j, line_type) == 0 && j == length - 2)cout << " "; //3
else if (a[i][j] == 1 && or_line(a, i - 1, j, line_type) && i == poz_i&&j == poz_j)cout << " \x99 ";//3
else if (a[i][j] == 1 && or_line(a, i - 1, j, line_type))cout << " ";//3
else if (a[i][j] == 1 && r_down(a, i, j, line_type) && ver_line(a, i, j + 2, line_type) == 0 && ver_line(a, i - 1, j + 1, line_type) && a[i + 1][j + 2] == 0 && i == poz_i&&j == poz_j)cout << " \x99 ";//4
else if (a[i][j] == 1 && r_down(a, i, j, line_type) && ver_line(a, i, j + 2, line_type) == 0 && ver_line(a, i - 1, j + 1, line_type) && a[i + 1][j + 2] == 0)cout << " ";//4
else if (a[i][j] == 1 && r_down(a, i, j, line_type) && i == poz_i&&j == poz_j)cout << " \x99 ";//3
else if (a[i][j] == 1 && r_down(a, i, j, line_type))cout << " ";//3
//limit left
else if (a[i][j] == 1 && a[i][j + 1] == 0 && ver_line(a, i - 1, j - 1, line_type) && j == length - 2 && i == poz_i&&j == poz_j)cout << " \x99";//3
else if (a[i][j] == 1 && a[i][j + 1] == 0 && ver_line(a, i - 1, j - 1, line_type) && j == length - 2 && ver_line(a, i, j + 2, line_type) == 0)cout << " ";//3
else if (a[i][j] == 1 && a[i][j + 1] == 0 && ver_line(a, i - 1, j - 1, line_type) && j != length - 2 && l_up(a, i, j + 1, line_type) && i == poz_i&&j == poz_j)cout << " \x99 ";//4
else if (a[i][j] == 1 && a[i][j + 1] == 0 && ver_line(a, i - 1, j - 1, line_type) && j != length - 2 && l_up(a, i, j + 1, line_type)) cout << " ";//4
else if (a[i][j] == 1 && a[i][j + 1] == 0 && ver_line(a, i - 1, j - 1, line_type) && j != length - 2 && i == poz_i&&j == poz_j)cout << " \x99 ";//4
else if (a[i][j] == 1 && a[i][j + 1] == 0 && ver_line(a, i - 1, j - 1, line_type) && j != length - 2) cout << " ";//4
}
//inside lines
if (or_line(a, i, j, line_type))cout << "\xCD\xCD\xCD";
if (plus_shape(a, i, j, line_type))cout << "\xCE";
else if (left_T(a, i, j, line_type))cout << "\xB9";
else if (right_T(a, i, j, line_type))cout << "\xCC";
else if (ver_line(a, i, j, line_type))cout << "\xBA";
else if (down_T(a, i, j, line_type))cout << "\xCA";
else if (up_T(a, i, j, line_type))cout << "\xCB";
else if (or_line(a, i, j - 1, line_type) && or_line(a, i, j + 1, line_type))cout << "\xCD";
//spaces #2
if (j % 2 == 1 && i != 0 && i != width - 1 && i != width - 1)
{
//if (a[i][j] == 0 && or_line(a, i, j - 2) && ver_line(a, i, j + 1) == 0&&ver_line(a,i-1,j+1)&&j-2==1)cout << " ";
if (a[i][j] == 1 && or_line(a, i, j, line_type) && a[i][j + 2] == 0 && r_up(a, i, j + 2, line_type) == 0) cout << " ";
if (a[i][j] == 1 && or_line(a, i - 1, j, line_type) && ver_line(a, i, j + 1, line_type) == 0 && ver_line(a, i, j - 1, line_type) == 0 && j != length - 2) cout << " ";
if (a[i][j] == 1 && ver_line(a, i - 1, j - 1, line_type) && ver_line(a, i - 1, j + 1, line_type) && or_line(a, i, j, line_type) == 0 && a[i + 1][j - 1] == 0 && l_down(a, i, j + 1, line_type) == 0)cout << " ";//3
}
}
}
void Movement(int a[100][100], int width, int length, int poz_i, int poz_j,int line_type[100][100])
{
int i = 0;
CursorPosition.X = 0;
CursorPosition.Y = 0;
SetConsoleCursorPosition(console, CursorPosition);
Labirinth_generator(a, width, length, poz_i, poz_j, line_type);
cout << "Moves: " << i<<endl;
while (poz_i != width - 2 || poz_j != length - 2)
{
CursorPosition.X = 0;
CursorPosition.Y = 0;
SetConsoleCursorPosition(console, CursorPosition);
switch (_getch())
{
case key_down:
{ if (or_line(a, poz_i + 1, poz_j, line_type) == 0 && poz_i != width - 2)
{
i++;
poz_i = poz_i + 2;
Labirinth_generator(a, width, length, poz_i, poz_j, line_type);
cout << "Moves: " << i << endl;
}}
break;
case key_up:
{ if (or_line(a, poz_i - 1, poz_j, line_type) == 0 && poz_i != 1)
{
i++;
poz_i = poz_i - 2;
Labirinth_generator(a, width, length, poz_i, poz_j, line_type);
cout << "Moves: " << i << endl;
}
}
break;
case key_left:
{ if (ver_line(a, poz_i, poz_j - 1, line_type) == 0 && poz_j != 1)
{
i++;
poz_j = poz_j - 2;
Labirinth_generator(a, width, length, poz_i, poz_j, line_type);
cout << "Moves: " << i << endl;
}}
break;
case key_rigth:
{if (ver_line(a, poz_i, poz_j + 1, line_type) == 0 && poz_j != length - 2)
{
i++;
poz_j = poz_j + 2;
Labirinth_generator(a, width, length, poz_i, poz_j, line_type);
cout << "Moves: " << i << endl;
}}
break;
}
}
cout << " YOU WON! " << endl;
}
int random_number(int size)
{
int random;
random = rand() % size + 1;
return random;
}
void empty_matrice(int a[100][100], int width, int length)
{
int i, j;
for (i = 0; i <= width; i++)
for (j = 0; j <= length; j++)
if (i == 0 || j == 0 || i == width || j == length)
a[i][j] = 9;
else a[i][j] = 0;
}
void show_mat(int a[100][100], int width, int length)
{
int i, j;
for (i = 0; i <= width; i++)
{
for (j = 0; j <= length; j++)
cout << a[i][j] << " ";
cout << endl;
}
}
void read_mat(int a[100][100], int width, int length)
{
int i, j;
for (i = 1; i < width; i++)
for (j = 1; j < length; j++)
f1 >> a[i][j];
}
//recursive division that doesn't work
void random_matrice(int a[100][100], int left_start, int right_up_corner, int up_start, int left_down_corner, int line_type[100][100])
{
int i, j, v_wal, o_wal,gap0, gap1, gap2, gap3, aux;
v_wal = random_number(right_up_corner / 2 - 1);
o_wal = random_number(left_down_corner / 2 - 1);
aux = left_down_corner / 2 - o_wal;
gap0= random_number(left_down_corner / 2 - aux);
gap1 = random_number(left_down_corner / 2 - o_wal);
aux = right_up_corner / 2 - v_wal;
gap2 = random_number(right_up_corner / 2 - aux);
gap3 = random_number(right_up_corner / 2 - v_wal);
for (j = up_start; j < left_down_corner; j++)
{
if (j != (o_wal + gap1) * 2 && j != (o_wal + gap1) * 2 - 1 && j != gap0 * 2 && j != gap0 * 2 - 1)
{
a[j][v_wal * 2] = 1;
a[j][v_wal * 2 + 1] = 1;
if (line_type[j][v_wal * 2] == 2) line_type[j][v_wal * 2] = 3;
else line_type[j][v_wal * 2] = 1;
}
}
if (a[left_down_corner][v_wal * 2] == 1 && a[left_down_corner][v_wal * 2 + 1] == 0)
if (a[left_down_corner-1][v_wal * 2] == 1 && a[left_down_corner-1][v_wal * 2 + 1] == 1)
a[left_down_corner][v_wal * 2 + 1] = 1;
if (a[left_down_corner][v_wal * 2] == 0 && a[left_down_corner][v_wal * 2 + 1] == 1)
if (a[left_down_corner - 1][v_wal * 2] == 1 && a[left_down_corner - 1][v_wal * 2 + 1] == 1)
a[left_down_corner][v_wal * 2 ] = 1;
for (j = left_start; j < right_up_corner; j++)
{
if (j != gap2 * 2 && j != gap2 * 2 - 1 && j != (gap3 + v_wal) * 2 && j != (gap3 + v_wal) * 2 - 1)
{
a[o_wal * 2][j] = 1;
a[o_wal * 2 + 1][j] = 1;
if (line_type[o_wal * 2][j] == 1) line_type[o_wal * 2][j] = 3;
else line_type[o_wal * 2][j] = 2;
}
}
// left up square
if (v_wal >=3 && o_wal >= 3)
random_matrice(a,left_start, v_wal * 2+1 , up_start, o_wal * 2+1, line_type);
// right up square
if (right_up_corner / 2 - v_wal >= 3 && o_wal >= 3)
random_matrice(a, v_wal * 2 + 1, right_up_corner,up_start, o_wal * 2+1, line_type);
//left_down square
if (v_wal >= 3&& left_down_corner / 2 - o_wal >=3)
random_matrice(a,left_start, v_wal * 2+1, o_wal * 2 + 1,left_down_corner, line_type);
//right down square
if (right_up_corner / 2 - v_wal >= 3 && left_down_corner / 2 - o_wal >= 3)
random_matrice(a, v_wal * 2 + 1, right_up_corner, o_wal * 2 + 1, left_down_corner, line_type);
}
void clear_screen()
{
CursorPosition.X = 0;
CursorPosition.Y = 0;
SetConsoleCursorPosition(console, CursorPosition);
int i, j;
for (i = 1; i <= 100; i++)
{
for (j = 1; j <= 110; j++)
cout << " ";
cout << endl;
}
}
void menu()
{
cout << endl << endl << endl << endl;
cout << " Press the key for the desired difficulty"<<endl<<endl<<endl<<endl;
cout << " 1.EASY"<<endl<<endl;
cout << " 2.MEDIUM"<<endl<<endl;
cout << " 3.HARD"<<endl<<endl;
}
void random_matrice_from_file(int a[100][100], int width, int length)
{
int i, j,x;
int a1[100][100], a2[100][100], a3[100][100], a4[100][100], a5[100][100];
if (width == 19 && length == 27)
{
for (i = 1; i < width; i++)
for (j = 1; j < length; j++)
f2 >> a1[i][j];
for (i = 1; i < width; i++)
for (j = 1; j < length; j++)
f2 >> a2[i][j];
for (i = 1; i < width; i++)
for (j = 1; j < length; j++)
f2 >> a3[i][j];
for (i = 1; i < width; i++)
for (j = 1; j < length; j++)
f2 >> a4[i][j];
for (i = 1; i < width; i++)
for (j = 1; j < length; j++)
f2 >> a5[i][j];
x = random_number(5);
if (x == 1)
for (i = 1; i < width; i++)
for (j = 1; j < length; j++)
a[i][j] = a1[i][j];
if (x == 2)
for (i = 1; i < width; i++)
for (j = 1; j < length; j++)
a[i][j] = a2[i][j];
if (x == 3)
for (i = 1; i < width; i++)
for (j = 1; j < length; j++)
a[i][j] = a3[i][j];
if (x == 4)
for (i = 1; i < width; i++)
for (j = 1; j < length; j++)
a[i][j] = a4[i][j];
if (x == 5)
for (i = 1; i < width; i++)
for (j = 1; j < length; j++)
a[i][j] = a5[i][j];
}
if (width == 19 && length == 19)
{
for (i = 1; i < width; i++)
for (j = 1; j < length; j++)
f1 >> a1[i][j];
for (i = 1; i < width; i++)
for (j = 1; j < length; j++)
f1 >> a2[i][j];
for (i = 1; i < width; i++)
for (j = 1; j < length; j++)
f1 >> a3[i][j];
for (i = 1; i < width; i++)
for (j = 1; j < length; j++)
f1 >> a4[i][j];
for (i = 1; i < width; i++)
for (j = 1; j < length; j++)
f1 >> a5[i][j];
x = random_number(5);
if (x == 1)
for (i = 1; i < width; i++)
for (j = 1; j < length; j++)
a[i][j] = a1[i][j];
if (x == 2)
for (i = 1; i < width; i++)
for (j = 1; j < length; j++)
a[i][j] = a2[i][j];
if (x == 3)
for (i = 1; i < width; i++)
for (j = 1; j < length; j++)
a[i][j] = a3[i][j];
if (x == 4)
for (i = 1; i < width; i++)
for (j = 1; j < length; j++)
a[i][j] = a4[i][j];
if (x == 5)
for (i = 1; i < width; i++)
for (j = 1; j < length; j++)
a[i][j] = a5[i][j];
}
if (width == 27 && length == 35)
{
for (i = 1; i < width; i++)
for (j = 1; j < length; j++)
f3 >> a1[i][j];
for (i = 1; i < width; i++)
for (j = 1; j < length; j++)
f3 >> a2[i][j];
for (i = 1; i < width; i++)
for (j = 1; j < length; j++)
f3 >> a3[i][j];
for (i = 1; i < width; i++)
for (j = 1; j < length; j++)
f3 >> a4[i][j];
for (i = 1; i < width; i++)
for (j = 1; j < length; j++)
f3 >> a5[i][j];
x = random_number(5);
if (x == 1)
for (i = 1; i < width; i++)
for (j = 1; j < length; j++)
a[i][j] = a1[i][j];
if (x == 2)
for (i = 1; i < width; i++)
for (j = 1; j < length; j++)
a[i][j] = a2[i][j];
if (x == 3)
for (i = 1; i < width; i++)
for (j = 1; j < length; j++)
a[i][j] = a3[i][j];
if (x == 4)
for (i = 1; i < width; i++)
for (j = 1; j < length; j++)
a[i][j] = a4[i][j];
if (x == 5)
for (i = 1; i < width; i++)
for (j = 1; j < length; j++)
a[i][j] = a5[i][j];
}
}
void maze()
{
cout << " \xC9\xCD\xCD\xBB \xC9\xCD\xCD\xBB \xC9\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xBB \xC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