base for developping teams
This commit is contained in:
parent
3280547830
commit
2f9e183eb7
10
.kdev4/PixelWars.kdev4
Normal file
10
.kdev4/PixelWars.kdev4
Normal file
@ -0,0 +1,10 @@
|
||||
[Buildset]
|
||||
BuildItems=@Variant(\x00\x00\x00\t\x00\x00\x00\x00\x01\x00\x00\x00\x0b\x00\x00\x00\x00\x01\x00\x00\x00\x12\x00P\x00i\x00x\x00e\x00l\x00W\x00a\x00r\x00s)
|
||||
|
||||
[Defines And Includes][Compiler]
|
||||
Name=GCC
|
||||
Path=gcc
|
||||
Type=GCC
|
||||
|
||||
[Project]
|
||||
VersionControlSupport=kdevgit
|
@ -20,9 +20,11 @@ endif
|
||||
|
||||
all : $(TARGET).$(LIB_PREFIX)
|
||||
|
||||
$(TARGET).$(LIB_PREFIX) : *.c
|
||||
$(CC) *.c -c $(FLAGS)
|
||||
$(AR) $(TARGET).$(LIB_PREFIX) *.o
|
||||
$(TARGET).$(LIB_PREFIX) : orange.o
|
||||
$(AR) $(TARGET).$(LIB_PREFIX) orange.o
|
||||
|
||||
%.o: %.c
|
||||
$(CC) -o $@ -c $< $(FLAGS)
|
||||
|
||||
clean :
|
||||
$(RM) *.o *.a *.stackdump *~
|
BIN
orange/orange.a
BIN
orange/orange.a
Binary file not shown.
409
orange/orange.c
409
orange/orange.c
@ -1,329 +1,122 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include "../team.h"
|
||||
|
||||
// Development in progress
|
||||
|
||||
//Structure definition
|
||||
enum{
|
||||
O_JOBLESS, O_MASTER, O_GATHERER, O_WOODCUTTER, O_MINER, O_NB_JOBS
|
||||
};
|
||||
|
||||
enum{
|
||||
O_NO_AIM, O_AIM_MASTER, O_AIM_SPAWN, O_AIM_SPOT
|
||||
};
|
||||
|
||||
#define ORANGE_SPAWN_X 0
|
||||
#define ORANGE_SPAWN_Y 0
|
||||
|
||||
#define ORANGE_MASTER_X 3
|
||||
#define ORANGE_MASTER_Y 3
|
||||
// Orange Hello World
|
||||
|
||||
typedef struct{
|
||||
char type; //the type of ressource that was found
|
||||
t_coord pos; // pos where ressource was found
|
||||
} t_orange_ressource_spot;
|
||||
t_coord pos;
|
||||
int new_born;
|
||||
int try;
|
||||
int brings_food;
|
||||
int last_dir;
|
||||
int last_action;
|
||||
} orange_data;
|
||||
|
||||
typedef struct{
|
||||
char name; // name of the dude
|
||||
t_coord pos; // position relative to the spawn
|
||||
char age;
|
||||
char job;
|
||||
char aim;
|
||||
char talking;
|
||||
char listening;
|
||||
t_orange_ressource_spot res_spot;
|
||||
char last_action;
|
||||
char last_dir;
|
||||
} t_orange_info;
|
||||
t_coord o_newPos(t_coord coord, int dir){
|
||||
t_coord new_coord = coord;
|
||||
switch(dir){
|
||||
case NORTH :
|
||||
new_coord.y++;
|
||||
break;
|
||||
case SOUTH :
|
||||
new_coord.y--;
|
||||
break;
|
||||
case WEST :
|
||||
new_coord.x++;
|
||||
break;
|
||||
case EAST :
|
||||
new_coord.x--;
|
||||
break;
|
||||
}
|
||||
return new_coord;
|
||||
}
|
||||
|
||||
//tools functions
|
||||
int orangeNewDir(t_orange_info*);
|
||||
t_coord orangeNewPos(t_coord, int);
|
||||
int orangeDistance(t_coord, int, int);
|
||||
//action function
|
||||
void orangeApplyAction(t_orange_info*,t_com*);
|
||||
void orangeMoveEffect(t_orange_info*);
|
||||
void orangePickEffect(t_orange_info*);
|
||||
void orangePutEffect(t_orange_info*);
|
||||
void orangeCommunicateEffect(t_orange_info*);
|
||||
void orangeWaitEffect(t_orange_info*, t_com*);
|
||||
//jobs function
|
||||
void orangeHatched(t_orange_info*);
|
||||
int o_abs(int val){
|
||||
return val > 0 ? val : -val;
|
||||
}
|
||||
|
||||
void orangeJobless(t_action*, t_orange_info*, t_com*, int);
|
||||
void orangeMaster(t_action*, t_orange_info*, t_com*, int);
|
||||
void orangeGatherer(t_action*, t_orange_info*, t_com*, int);
|
||||
int o_dist(t_coord coord, int x, int y){
|
||||
return o_abs(coord.x-x) + o_abs(coord.y-y);
|
||||
}
|
||||
|
||||
t_action orange_update(void* my_info, t_com* com_data, int success){
|
||||
t_orange_info* data = (t_orange_info*)my_info;
|
||||
t_action orange_update(){
|
||||
t_action action;
|
||||
int i, type;
|
||||
|
||||
if(data->age == 0){
|
||||
orangeHatched(data);
|
||||
int success = getSuccess();
|
||||
orange_data* data = (orange_data*)getMemory();
|
||||
|
||||
if(!data->new_born){
|
||||
success = 0;
|
||||
data->new_born = 1;
|
||||
}
|
||||
|
||||
if (!success){
|
||||
action.type = data->last_action;
|
||||
action.dir = data->last_dir;
|
||||
if(data->last_action == MOVE){
|
||||
if(success)
|
||||
data->pos = o_newPos(data->pos, data->last_dir);
|
||||
}
|
||||
|
||||
if(data->try && success)
|
||||
data->brings_food = 1;
|
||||
data->try = 0;
|
||||
|
||||
if(data->brings_food){
|
||||
int distance = o_dist(data->pos, 0, 0);
|
||||
if(distance == 1){
|
||||
action.type = WAIT;
|
||||
|
||||
action.dir = 0;
|
||||
for(i=0; i<4; i++){
|
||||
type = getNear(i);
|
||||
if(type == SPAWN){
|
||||
action.dir = i;
|
||||
action.type = PUT;
|
||||
data->brings_food = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
action.type = MOVE;
|
||||
do{
|
||||
action.dir = rand()%4;
|
||||
}while(o_dist(o_newPos(data->pos, action.dir), 0, 0) > distance && distance != 0);
|
||||
|
||||
}
|
||||
data->last_dir = action.dir;
|
||||
data->last_action = action.type;
|
||||
return action;
|
||||
}
|
||||
|
||||
orangeApplyAction(data,com_data);
|
||||
|
||||
switch(data->job){
|
||||
case O_JOBLESS:
|
||||
orangeJobless(&action, data, com_data, success);
|
||||
break;
|
||||
case O_MASTER:
|
||||
orangeMaster(&action, data, com_data, success);
|
||||
break;
|
||||
case O_GATHERER:
|
||||
orangeGatherer(&action,data, com_data, success);
|
||||
break;
|
||||
case O_WOODCUTTER:
|
||||
case O_MINER:
|
||||
break;
|
||||
for(i=0; i<4; i++){
|
||||
type = getNear(i);
|
||||
if(type == BERRIES || type == TREE || type == IRON_ORE || type == ROCK){
|
||||
action.type = WORK;
|
||||
action.dir = i;
|
||||
data->last_dir = action.dir;
|
||||
data->last_action = action.type;
|
||||
return action;
|
||||
}else if(type == FOOD){
|
||||
action.type = PICK;
|
||||
action.dir = i;
|
||||
data->try = 1;
|
||||
data->last_dir = action.dir;
|
||||
data->last_action = action.type;
|
||||
return action;
|
||||
}
|
||||
}
|
||||
data->last_action = action.type;
|
||||
|
||||
action.type = MOVE;
|
||||
do{
|
||||
action.dir = (data->last_dir + rand()%3)%4;
|
||||
type = getNear(action.dir);
|
||||
}while(type == WALL
|
||||
&& type == ROCK
|
||||
&& type == BEDROCK
|
||||
&& type == IRON_ORE
|
||||
&& type == TREE
|
||||
&& type == LIBRARY);
|
||||
data->last_dir = action.dir;
|
||||
data->last_action = action.type;
|
||||
return action;
|
||||
}
|
||||
|
||||
void orangeHatched(t_orange_info* data){
|
||||
data->age++;
|
||||
data->job = O_JOBLESS;
|
||||
data->aim = O_AIM_MASTER;
|
||||
data->pos.x=0;
|
||||
data->pos.y=0;
|
||||
}
|
||||
|
||||
void orangeApplyAction(t_orange_info* data,t_com* com_data){
|
||||
switch(data->last_action){
|
||||
case MOVE:
|
||||
data->pos=orangeNewPos(data->pos, data->last_dir);
|
||||
orangeMoveEffect(data);
|
||||
break;
|
||||
case PICK:
|
||||
orangePickEffect(data);
|
||||
break;
|
||||
case PUT:
|
||||
orangePutEffect(data);
|
||||
break;
|
||||
case COMMUNICATE:
|
||||
orangeCommunicateEffect(data);
|
||||
break;
|
||||
case WAIT:
|
||||
orangeWaitEffect(data,com_data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void orangeMoveEffect(t_orange_info* data){
|
||||
int dist_to_master;
|
||||
switch(data->job){
|
||||
case O_JOBLESS:
|
||||
dist_to_master = orangeDistance(data->pos,ORANGE_MASTER_X,ORANGE_MASTER_Y);
|
||||
if(dist_to_master == 0){
|
||||
data->job=O_MASTER;
|
||||
data->listening = 1;
|
||||
data->talking = 0;
|
||||
}else if(dist_to_master == 1)
|
||||
data->talking = 1;
|
||||
break;
|
||||
case O_GATHERER:
|
||||
if (getInventory() == -1){
|
||||
if (orangeDistance(data->pos,data->res_spot.pos.x, data->res_spot.pos.y) == 0){
|
||||
data->aim = O_NO_AIM;
|
||||
}
|
||||
}else{
|
||||
if(orangeDistance(data->pos, ORANGE_SPAWN_X, ORANGE_SPAWN_Y) == 1){
|
||||
data->aim=O_AIM_SPOT;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case O_WOODCUTTER:
|
||||
case O_MINER:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void orangePickEffect(t_orange_info* data){
|
||||
switch(data->job){
|
||||
case O_GATHERER:
|
||||
data->aim=O_AIM_SPAWN;
|
||||
data->res_spot.type = getInventory();
|
||||
data->res_spot.pos = data->pos;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void orangePutEffect(t_orange_info* data){
|
||||
switch(data->job){
|
||||
case O_GATHERER:
|
||||
data->aim=O_AIM_SPOT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void orangeCommunicateEffect(t_orange_info* data){
|
||||
data->listening = 1;
|
||||
data->talking = 0;
|
||||
}
|
||||
|
||||
void orangeWaitEffect(t_orange_info* data, t_com* com_data){
|
||||
switch(data->job){
|
||||
case O_JOBLESS:
|
||||
if ((com_data != NULL)){
|
||||
if (com_data->data[0] == 1){
|
||||
switch(com_data->data[1]){
|
||||
case O_GATHERER:
|
||||
printf("Become a gatherer");
|
||||
data->job = O_GATHERER;
|
||||
data->listening = 0;
|
||||
data->aim = O_NO_AIM;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case O_MASTER:
|
||||
if (com_data != NULL){
|
||||
printf("got a message \n");
|
||||
data->talking = 1;
|
||||
}else{
|
||||
data->talking = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// job functions
|
||||
void orangeJobless(t_action* action, t_orange_info* data, t_com* com_data, int success){
|
||||
int dir_to_master;
|
||||
|
||||
dir_to_master = orangeNewDir(data);
|
||||
|
||||
if(data->listening){
|
||||
action->type=WAIT;
|
||||
action->dir=0;
|
||||
return;
|
||||
}
|
||||
if (data->talking){
|
||||
if (getNear(dir_to_master) == DUDE){
|
||||
action->type = COMMUNICATE;
|
||||
action->dir = dir_to_master;
|
||||
action->com_data.data[0]=1;
|
||||
return;
|
||||
}
|
||||
}
|
||||
action->type = MOVE;
|
||||
action->dir = dir_to_master;
|
||||
return;
|
||||
}
|
||||
|
||||
void orangeMaster(t_action* action, t_orange_info* data, t_com* com_data, int success){
|
||||
if (data->talking){
|
||||
printf("talking\n");
|
||||
action->type = COMMUNICATE;
|
||||
action->dir = com_data->flag;
|
||||
action->com_data.data[0] = 1;
|
||||
action->com_data.data[1] = O_GATHERER;
|
||||
}else{
|
||||
action->type = WAIT;
|
||||
action->dir=0;
|
||||
}
|
||||
}
|
||||
|
||||
void orangeGatherer(t_action* action, t_orange_info* data, t_com* com_data, int success){
|
||||
int i,t;
|
||||
//action choice
|
||||
for(i=0;i<4;i++){
|
||||
t = getNear(i);
|
||||
switch(t){
|
||||
case BERRIES:
|
||||
action->type = WORK;
|
||||
action->dir = i;
|
||||
return;
|
||||
case FOOD:
|
||||
if(getInventory() == -1){
|
||||
action->type = PICK;
|
||||
action->dir = i;
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case SPAWN:
|
||||
if(getInventory() == FOOD){
|
||||
action->type = PUT;
|
||||
action->dir = i;
|
||||
return;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
action->type= MOVE;
|
||||
action->dir = orangeNewDir(data);
|
||||
return;
|
||||
}
|
||||
|
||||
//orange tools
|
||||
int orangeNewDir(t_orange_info* data){
|
||||
int dir;
|
||||
int current_dist,new_dist;
|
||||
int x,y;
|
||||
switch(data->aim){
|
||||
case O_NO_AIM:
|
||||
return (data->last_dir + rand()%3 )%4;
|
||||
case O_AIM_MASTER:
|
||||
x = ORANGE_MASTER_X;
|
||||
y = ORANGE_MASTER_Y;
|
||||
break;
|
||||
case O_AIM_SPAWN:
|
||||
x = ORANGE_SPAWN_X;
|
||||
y = ORANGE_SPAWN_Y;
|
||||
break;
|
||||
case O_AIM_SPOT:
|
||||
x = data->res_spot.pos.x;
|
||||
y = data->res_spot.pos.y;
|
||||
break;
|
||||
}
|
||||
current_dist = orangeDistance(data->pos,x,y);
|
||||
if (current_dist == 0) return 0;
|
||||
do{
|
||||
dir= rand()%4;
|
||||
new_dist = orangeDistance(orangeNewPos(data->pos,dir),x,y);
|
||||
}while(current_dist <= new_dist);
|
||||
|
||||
if (getNear(dir) == DUDE || getNear(dir) == TREE || getNear(dir) == ROCK || getNear(dir) == IRON_ORE){
|
||||
int offset = (rand()%3)-1;
|
||||
dir+=offset;
|
||||
dir%=4;
|
||||
}
|
||||
return dir;
|
||||
}
|
||||
t_coord orangeNewPos(t_coord pos, int dir){
|
||||
t_coord new_pos = pos;
|
||||
switch(dir){
|
||||
case NORTH:
|
||||
new_pos.y++;
|
||||
break;
|
||||
case SOUTH:
|
||||
new_pos.y--;
|
||||
break;
|
||||
case EAST:
|
||||
new_pos.x++;
|
||||
break;
|
||||
case WEST:
|
||||
new_pos.x--;
|
||||
break;
|
||||
}
|
||||
return new_pos;
|
||||
}
|
||||
int orangeDistance(t_coord c, int x, int y){
|
||||
return abs(x-c.x) + abs(y-c.y);
|
||||
}
|
@ -20,8 +20,8 @@ endif
|
||||
|
||||
all : $(TARGET).$(LIB_PREFIX)
|
||||
|
||||
$(TARGET).$(LIB_PREFIX) : purple.o tools.o king.o worker.o
|
||||
$(AR) $(TARGET).$(LIB_PREFIX) purple.o tools.o king.o worker.o
|
||||
$(TARGET).$(LIB_PREFIX) : purple.o
|
||||
$(AR) $(TARGET).$(LIB_PREFIX) purple.o
|
||||
|
||||
%.o: %.c
|
||||
$(CC) -o $@ -c $< $(FLAGS)
|
||||
|
31
purple/job.h
31
purple/job.h
@ -1,31 +0,0 @@
|
||||
#ifndef P_JOB_H
|
||||
#define P_JOB_H
|
||||
|
||||
#include "../team.h"
|
||||
|
||||
enum{ // jobs
|
||||
P_JOBLESS,
|
||||
P_KING,
|
||||
P_WORKER,
|
||||
P_EXPLORER
|
||||
};
|
||||
|
||||
typedef struct{
|
||||
char identity;
|
||||
char job;
|
||||
char request_type;
|
||||
char area_x;
|
||||
char area_y;
|
||||
char work_type;
|
||||
char amount;
|
||||
} p_request;
|
||||
|
||||
t_action p_jobless_ia();
|
||||
|
||||
t_action p_king_ia();
|
||||
|
||||
t_action p_explorer_ia();
|
||||
|
||||
t_action p_worker_ia();
|
||||
|
||||
#endif // P_JOB_H
|
@ -1,51 +0,0 @@
|
||||
#include <stdlib.h>
|
||||
#include "job.h"
|
||||
|
||||
typedef struct{
|
||||
char job;
|
||||
t_coord pos;
|
||||
char identity;
|
||||
int last_dir;
|
||||
int last_action;
|
||||
|
||||
int population;
|
||||
int nb_explorers;
|
||||
int nb_workers;
|
||||
unsigned char town_done;
|
||||
unsigned char town[8];
|
||||
unsigned char country_done;
|
||||
unsigned char country[8];
|
||||
} purple_data_king;
|
||||
|
||||
t_action p_king_ia(){
|
||||
t_action action;
|
||||
purple_data_king* data = getMemory();
|
||||
action.type = WAIT;
|
||||
if(data->pos.x != -1 || data->pos.y != -2)
|
||||
data->job = P_JOBLESS;
|
||||
else{
|
||||
t_com* com_data = getComData();
|
||||
p_request* request = ((void*)com_data)+sizeof(int);
|
||||
p_request answer;
|
||||
if(com_data != NULL){
|
||||
action.dir = com_data->flag;
|
||||
action.type = COMMUNICATE;
|
||||
if(request->identity < 1)
|
||||
answer.identity = data->population++; // temp way to handle demography
|
||||
if(request->job == P_WORKER)
|
||||
data->nb_workers--;
|
||||
if(request->job == P_EXPLORER)
|
||||
data->nb_explorers--;
|
||||
if(data->nb_explorers*2 > data->nb_workers){
|
||||
answer.job = P_WORKER;
|
||||
|
||||
}else{
|
||||
answer.job = P_EXPLORER;
|
||||
|
||||
}
|
||||
|
||||
// send message
|
||||
}
|
||||
}
|
||||
return action;
|
||||
}
|
BIN
purple/purple.a
BIN
purple/purple.a
Binary file not shown.
@ -1,20 +1,49 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "../team.h"
|
||||
#include "job.h"
|
||||
#include "tools.h"
|
||||
|
||||
#define P_READY 0
|
||||
// Purple Hello World
|
||||
|
||||
t_action purple_ia();
|
||||
typedef struct{
|
||||
t_coord pos;
|
||||
int new_born;
|
||||
int try;
|
||||
int brings_food;
|
||||
int last_dir;
|
||||
int last_action;
|
||||
} purple_data;
|
||||
|
||||
t_coord p_newPos(t_coord coord, int dir){
|
||||
t_coord new_coord = coord;
|
||||
switch(dir){
|
||||
case NORTH :
|
||||
new_coord.y++;
|
||||
break;
|
||||
case SOUTH :
|
||||
new_coord.y--;
|
||||
break;
|
||||
case WEST :
|
||||
new_coord.x++;
|
||||
break;
|
||||
case EAST :
|
||||
new_coord.x--;
|
||||
break;
|
||||
}
|
||||
return new_coord;
|
||||
}
|
||||
|
||||
int p_abs(int val){
|
||||
return val > 0 ? val : -val;
|
||||
}
|
||||
|
||||
int p_dist(t_coord coord, int x, int y){
|
||||
return p_abs(coord.x-x) + p_abs(coord.y-y);
|
||||
}
|
||||
|
||||
t_action purple_update(){
|
||||
t_action action;
|
||||
int i, type;
|
||||
|
||||
if(P_READY)
|
||||
return purple_ia();
|
||||
|
||||
int success = getSuccess();
|
||||
purple_data* data = (purple_data*)getMemory();
|
||||
|
||||
@ -25,7 +54,7 @@ t_action purple_update(){
|
||||
|
||||
if(data->last_action == MOVE){
|
||||
if(success)
|
||||
data->pos = newPos(data->pos, data->last_dir);
|
||||
data->pos = p_newPos(data->pos, data->last_dir);
|
||||
}
|
||||
|
||||
if(data->try && success)
|
||||
@ -33,7 +62,7 @@ t_action purple_update(){
|
||||
data->try = 0;
|
||||
|
||||
if(data->brings_food){
|
||||
int distance = dist(data->pos, 0, 0);
|
||||
int distance = p_dist(data->pos, 0, 0);
|
||||
if(distance == 1){
|
||||
action.type = WAIT;
|
||||
|
||||
@ -51,7 +80,7 @@ t_action purple_update(){
|
||||
action.type = MOVE;
|
||||
do{
|
||||
action.dir = rand()%4;
|
||||
}while(dist(newPos(data->pos, action.dir), 0, 0) > distance && distance != 0);
|
||||
}while(p_dist(p_newPos(data->pos, action.dir), 0, 0) > distance && distance != 0);
|
||||
|
||||
}
|
||||
data->last_dir = action.dir;
|
||||
@ -91,36 +120,3 @@ t_action purple_update(){
|
||||
data->last_action = action.type;
|
||||
return action;
|
||||
}
|
||||
|
||||
t_action purple_ia(){
|
||||
t_action action;
|
||||
|
||||
|
||||
int critic = check_critic_situation();
|
||||
if(critic != -1){
|
||||
action.dir = critic;
|
||||
action.type = ATTACK;
|
||||
return action;
|
||||
}
|
||||
|
||||
char* job = (char*)getMemory();
|
||||
switch(*job){
|
||||
case P_KING :
|
||||
action = p_king_ia();
|
||||
break;
|
||||
case P_JOBLESS :
|
||||
action = p_jobless_ia();
|
||||
break;
|
||||
case P_WORKER :
|
||||
action = p_worker_ia();
|
||||
break;
|
||||
case P_EXPLORER :
|
||||
action = p_explorer_ia();
|
||||
break;
|
||||
default :
|
||||
*job = P_JOBLESS;
|
||||
action.type = WAIT;
|
||||
break;
|
||||
}
|
||||
return action;
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
#include "tools.h"
|
||||
|
||||
t_coord newPos(t_coord coord, int dir){
|
||||
t_coord new_coord = coord;
|
||||
switch(dir){
|
||||
case NORTH :
|
||||
new_coord.y++;
|
||||
break;
|
||||
case SOUTH :
|
||||
new_coord.y--;
|
||||
break;
|
||||
case WEST :
|
||||
new_coord.x++;
|
||||
break;
|
||||
case EAST :
|
||||
new_coord.x--;
|
||||
break;
|
||||
}
|
||||
return new_coord;
|
||||
}
|
||||
|
||||
int abs(int val){
|
||||
return val > 0 ? val : -val;
|
||||
}
|
||||
|
||||
int dist(t_coord coord, int x, int y){
|
||||
return abs(coord.x-x) + abs(coord.y-y);
|
||||
}
|
||||
|
||||
int check_critic_situation(){
|
||||
int i;
|
||||
for(i=0; i<4; i++){
|
||||
if(getNear(i) == DUDE && getInfo(i) == ORANGE)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
#ifndef P_TOOLS_H
|
||||
#define P_TOOLS_H
|
||||
|
||||
#include "../team.h"
|
||||
|
||||
typedef struct{
|
||||
t_coord pos;
|
||||
int new_born;
|
||||
int try;
|
||||
int brings_food;
|
||||
int last_dir;
|
||||
int last_action;
|
||||
} purple_data;
|
||||
|
||||
t_coord newPos(t_coord coord, int dir);
|
||||
|
||||
int abs(int val);
|
||||
|
||||
int dist(t_coord coord, int x, int y);
|
||||
|
||||
int check_critic_situation();
|
||||
|
||||
#endif // P_TOOLS_H
|
@ -1,42 +0,0 @@
|
||||
#include "job.h"
|
||||
|
||||
typedef struct{
|
||||
char job;
|
||||
t_coord pos;
|
||||
char identity;
|
||||
int last_dir;
|
||||
int last_action;
|
||||
|
||||
int work_type; // worker
|
||||
int amount_needed; // worker
|
||||
t_coord storage; // worker
|
||||
t_coord target_area; // worker and explorer
|
||||
} purple_data_worker;
|
||||
|
||||
t_action p_jobless_ia(){
|
||||
t_action action;
|
||||
// goto (-1, -1)
|
||||
// check NORTH
|
||||
// empty -> be KING and go NORTH
|
||||
// KING -> ask for identity
|
||||
return action;
|
||||
}
|
||||
|
||||
t_action p_explorer_ia(){
|
||||
t_action action;
|
||||
// goto nearest spot of the area
|
||||
// start the loop
|
||||
// at end of loop, go back to KING to get new AREA
|
||||
return action;
|
||||
}
|
||||
|
||||
t_action p_worker_ia(){
|
||||
t_action action;
|
||||
// loop :
|
||||
// goto area
|
||||
// search for requested resource
|
||||
// bring it back to storage and amount--
|
||||
// while(amount > 0)
|
||||
// go see the master to get new goal
|
||||
return action;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user