Starship Code Contest  0.1
A real student nightmare...
rand_move_info.c
Go to the documentation of this file.
1 
14 #include <stdio.h>
15 #include <stdlib.h>
16 #include <assert.h>
17 #include "../includes/acquisition.h"
18 
19 static int turn_move=0;
20 static int turn_radar=0;
21 
22 static double move_modif=0;
23 static double radar_modif=0;
24 
25 static char me[18]="rand_move_info.so";
26 
42  View_starship* S=NULL;
43  int nb_starship;
44  View_missile* M=NULL;
45  int nb_missile;
46  int i;
47 
48  d->move = 1;
49  if (turn_move == 37){
50  turn_move=0;
51  move_modif = 0.05*(double)((rand() % 3) - 1);
52  }
53  else
54  turn_move++;
55  if (turn_radar == 15){
56  turn_radar = 0;
57  radar_modif = 0.15*(double)((rand() % 3) - 1);
58  }
59  else
60  turn_radar++;
61 
62  d->angle_starship = move_modif;
63  d->angle_radar = radar_modif;
64 
65  printf("\n ---- FRAME INFORMATIONS ---- \n");
66  printf("My position in abscicca : %lf\n", get_x(me));
67  printf("My position in ordinate : %lf\n", get_y(me));
68  printf("My life point : %d\n", get_life(me));
69  printf("My gear (1=front, 0=neutral, -1=reverse) : %d\n", get_life(me));
70  printf("My team number : %d\n", get_nb_team(me));
71  printf("My gun status (0 if ready for fire) : %d\n", get_nb_team(me));
72  printf("My moving angle : %lf\n", get_move_angle(me));
73  printf("My gun angle : %lf\n", get_gun_angle(me));
74  printf("My radar angle : %lf\n", get_radar_angle(me));
75 
76  get_scan_from_radar(me, &S, &nb_starship, &M, &nb_missile);
77 
78  printf("\n--> What my radar see :\n");
79  for (i=0 ; i<nb_starship ; i++){
80  printf("I see a starship : \n");
81  printf("x = %lf\n", S[i].x);
82  printf("y = %lf\n", S[i].y);
83  printf("moving angle = %lf\n", S[i].angle_move);
84  printf("gear = %d\n", S[i].speed);
85  printf("team number = %d\n", S[i].nb_team);
86  }
87  for (i=0 ; i<nb_missile ; i++){
88  printf("I see a missile : \n");
89  printf("x = %lf\n", M[i].x);
90  printf("y = %lf\n", M[i].y);
91  printf("moving angle = %lf\n", M[i].angle_move);
92  }
93  assert(scanf("%*c") == 0);
94 }
95 
104 void initialize_my_AI(void){
105  return ;
106 }
107 
116 void clean_my_AI(void){
117  return ;
118 }
void decision_frame(Decision_frame *d)
Function which produce a random move and scan elements with the radar.
double get_radar_angle(char *me)
Get the angle of the radar of the starship piloted by the plugin me.
double get_y(char *me)
Get the position in ordinate of the starship piloted by the plugin me.
double angle_radar
Definition: acquisition.h:25
void initialize_my_AI(void)
Initialization of this test plugin.
This structure gathers information scaned by the radar about other starships.
Definition: acquisition.h:38
double get_x(char *me)
Get the position in absicca of the starship piloted by the plugin me.
int get_nb_team(char *me)
Get the number of the team of the starship piloted by the plugin me.
void get_scan_from_radar(char *me, View_starship **S, int *nb_starship, View_missile **M, int *nb_missile)
Set information that the radar can get in its current position.
This structure gathers the information needed to pilot a starship each frame.
Definition: acquisition.h:21
double get_gun_angle(char *me)
Get the angle of the gun of the starship piloted by the plugin me.
double angle_starship
Definition: acquisition.h:23
This structure gathers information scaned by the radar about missiles.
Definition: acquisition.h:55
double get_move_angle(char *me)
Get the moving angle of the starship piloted by the plugin me.
int get_life(char *me)
Get the life of the starship piloted by the plugin me.
void clean_my_AI(void)
Clean this test plugin.