-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBasePlateau.cpp
More file actions
47 lines (37 loc) · 1.29 KB
/
BasePlateau.cpp
File metadata and controls
47 lines (37 loc) · 1.29 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
#include <iostream>
#include <vector>
#include <cstdlib>
#include <random>
using namespace std;
typedef vector<vector<int> > Plateau;
#include "Jeu2048.h"
Plateau plateauVide(){
Plateau plateau = {{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}};
return plateau;
}
int NumberGenerator(int a, int b){
int nRand ;
nRand= a + (int)((float)rand() * (b-a+1) / (RAND_MAX-1)) ;
return nRand;
}
int tireDeuxOuQuatre(){
int probaNbr = NumberGenerator(1,10);
if(probaNbr == 10){
return 4;
} else {
return 2;
}
}
Plateau plateauInitial(Plateau plateau){
int indiceI = NumberGenerator(0,plateau.size()-1);
int indiceJ = NumberGenerator(0,plateau[0].size()-1);
plateau[indiceI][indiceJ] = tireDeuxOuQuatre();
int indiceI2 = NumberGenerator(0,plateau.size()-1);
int indiceJ2 = NumberGenerator(0,plateau[0].size()-1);
while(indiceI2 == indiceI and indiceJ2 == indiceJ){
int indiceI2 = NumberGenerator(0,plateau.size()-1);
int indiceJ2 = NumberGenerator(0,plateau[0].size()-1);
}
plateau[indiceI2][indiceJ2] = tireDeuxOuQuatre();
return plateau;
}