50 lines
1.2 KiB
C
50 lines
1.2 KiB
C
|
#include "blocus.h"
|
||
|
|
||
|
void CoordIA(int grille, int *coordX, int *coordY) {
|
||
|
int aleatoirex, aleatoirey;
|
||
|
srand(time(NULL));
|
||
|
aleatoirex = rand();
|
||
|
do {
|
||
|
aleatoirex = aleatoirex / 4;
|
||
|
} while (aleatoirex > grille);
|
||
|
aleatoirey = rand();
|
||
|
do {
|
||
|
aleatoirey = aleatoirey / 4;
|
||
|
} while (aleatoirey > grille);
|
||
|
|
||
|
*coordX = aleatoirex;
|
||
|
*coordY = aleatoirey;
|
||
|
}
|
||
|
|
||
|
void CoordBlocageIA(int grille, int *blocX, int *blocY) {
|
||
|
int aleatoirex, aleatoirey;
|
||
|
srand(time(NULL));
|
||
|
aleatoirex = rand();
|
||
|
do {
|
||
|
aleatoirex = aleatoirex / 3;
|
||
|
} while (aleatoirex > grille);
|
||
|
aleatoirey = rand();
|
||
|
do {
|
||
|
aleatoirey = aleatoirey / 3;
|
||
|
} while (aleatoirey > grille);
|
||
|
*blocX = aleatoirex;
|
||
|
*blocY = aleatoirey;
|
||
|
}
|
||
|
|
||
|
void DeplacementIAX(int grille, int *deplacementX) {
|
||
|
int aleatoirex;
|
||
|
srand(time(NULL));
|
||
|
do {
|
||
|
aleatoirex = rand() % 3 - 1; /*Génère -1, 0 ou 1*/
|
||
|
} while (aleatoirex > grille);
|
||
|
*deplacementX = aleatoirex;
|
||
|
}
|
||
|
|
||
|
void DeplacementIAY(int grille, int *deplacementY) {
|
||
|
int aleatoirey;
|
||
|
srand(time(NULL));
|
||
|
do {
|
||
|
aleatoirey = rand() % 3 - 1; /*Génère -1, 0 ou 1*/
|
||
|
} while (aleatoirey > grille);
|
||
|
*deplacementY = aleatoirey;
|
||
|
}
|