forked from Aisthetic/GoGame
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.c
More file actions
52 lines (49 loc) · 1.41 KB
/
Copy pathutils.c
File metadata and controls
52 lines (49 loc) · 1.41 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
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "logic.h"
#include "game.h"
#include <time.h>
int compare(Token token1,Token token2){//Comparer deux tokens
return (token1.X == token2.X && token1.Y == token2.Y)?1:0;
}
int checkIfTokenisInTeam(Team team , Token token){
for(int i = 0 ; i++ ; i<team.MembersCount){
if(compare(token,team.Members[i])) {
return 1;
}
}
return 0;
}
Team teamUnion(Team team1, Team team2)//L'union de deux teams
{
printf("Union de deux teams \n");
for (int i = 0; i<team1.MembersCount; i++){
printf("team1 member (%d,%d) \n",team1.Members[i].X,team1.Members[i].Y);
}
for (int i = 0; i<team2.MembersCount; i++){
printf("team2 member (%d,%d) \n",team2.Members[i].X,team2.Members[i].Y);
}
for(int i = 0; i < team2.MembersCount;i ++ ){
if(checkIfTokenisInTeam(team1,team2.Members[i])==0)
team1.addMember(&team1,team2.Members[i]);
else
printf("already in team");
}
printf("result\n");
for (int i = 0; i<team1.MembersCount; i++){
printf("Membre (%d,%d) \n",team1.Members[i].X,team1.Members[i].Y);
}
return team1;
}
void copyMatrix(void** a,void** c){
int i;
for(i = 0; i<9; i++)
{
memcpy(&a[i], &c[i], sizeof(c[0]));
}
}
int randomInt(int min, int max){
srand(time(NULL));
return rand() % (max - min) + min + 1;
}