Skip to content

Commit

Permalink
Documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasRives committed Jul 20, 2020
1 parent f0f0c17 commit 7cb5162
Show file tree
Hide file tree
Showing 12 changed files with 117 additions and 8 deletions.
2 changes: 1 addition & 1 deletion strategy/BottomLidar.pde
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This class simulate the behaviour of a bottom lidar
* This class simulate the behaviour of the bottom lidars
*/
class BottomLidar extends Sensor
{
Expand Down
2 changes: 1 addition & 1 deletion strategy/GameOver.pde
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class GameOver extends Task
}

/**
* Simulate the thing to do at the end of the timer
* Simulate what to do at the end of the timer
*/
@Override
void do_task()
Expand Down
2 changes: 1 addition & 1 deletion strategy/Lighthouse.pde
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Lighthouse extends Task
int lighthouse_wait;

/**
* The class' constructor
* The constructor of Lighthouse
* @param id: the identifier of the task
* @param points: the points given by the task
* @param position: the location of this task
Expand Down
15 changes: 15 additions & 0 deletions strategy/RTSRob.pde
Original file line number Diff line number Diff line change
@@ -1,15 +1,30 @@
/**
* This class represent our robot
*/
class RTSRob extends Robot
{
/* The weathercock's color detected by our robot */
int detected_color;

/* A boolean that indicate if the flag is deployed*/
boolean flag_deployed;

/**
* Constructor of our robot
* @param pos: the initial position of the robot
* @param angle: the initial position of the robot
* @param sensors: the list of sensors of our robot
*/
RTSRob(Pos position, float angle, ArrayList<Sensor> sensors)
{
super(position, angle, sensors);
this.detected_color = NO_COLOR;
this.flag_deployed = false;
}

/**
* Draw our robot, with the sensors if they can be reresented
*/
@Override
void draw_robot()
{
Expand Down
8 changes: 7 additions & 1 deletion strategy/Robot.pde
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Robot


/**
* Constructor of Robot
* Constructor of Robot (without sensors, probably the opponent)
* @param pos: the initial position of the robot
* @param angle: the initial position of the robot
*/
Expand All @@ -46,6 +46,12 @@ class Robot
}
}

/**
* Constructor of Robot (with sensors, probably the our robot)
* @param pos: the initial position of the robot
* @param angle: the initial position of the robot
* @param sensors_list: the list of sensors of the robot
*/
Robot(Pos pos, float angle, ArrayList<Sensor> sensors_list)
{
this.position = pos;
Expand Down
4 changes: 4 additions & 0 deletions strategy/Sensor.pde
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/**
* This abstract class represent the sensors
* It contains functions that must be implemented if you create a sensor
*/
abstract class Sensor
{
/**
Expand Down
23 changes: 23 additions & 0 deletions strategy/Strat.pde
Original file line number Diff line number Diff line change
@@ -1,11 +1,28 @@
/**
* This class is our strategy
*/
class Strat extends ManageOpponent
{
/* The identifier of the current task that correspond to its
place in tab_task*/
int id_current_task;

/* Beginnig of the match */
int time;

/* Our score */
int score;

/* The list of tasks to do classified in the order of completion*/
ArrayList<Integer> tasks_order = new ArrayList<Integer>();

/* The list of tasks that must be done */
ArrayList<Task> tab_tasks = new ArrayList<Task>();

/**
* The constructor of the class
* @param robot: the robot that must fllow the strategy
*/
Strat(RTSRob robot)
{
super(robot);
Expand Down Expand Up @@ -124,6 +141,12 @@ class Strat extends ManageOpponent
return time_left < (tab_tasks.get(TASK_FLAG).max_time + pos.dist(robot.position)/SLOW);
}

/**
* Move in the array "tasks_order" a task from the index "index_start" to
* the index "index_end"
* @param index_start: index of the task to move
* @param index_end: index where the task has to be moved
*/
void changeTaskOrder(int index_start, int index_end)
{
if (index_start == index_end || index_start >= this.tasks_order.size() || index_end >= this.tasks_order.size()
Expand Down
25 changes: 23 additions & 2 deletions strategy/Task.pde
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,22 @@
*/
abstract class Task
{
/* The identifier of the a task */
int id;

/* The points earned if we accomplish the task */
int points;

/* The position of the task */
Pos position;

/* Represent the state of the task */
int done;

/* The max time this task should last */
long max_time;

/* An ArrayList of checkpoints we need to reach to acomplish the task */
ArrayList<Pos> checkpoints = new ArrayList<Pos>();

/**
Expand Down Expand Up @@ -68,22 +79,32 @@ abstract class Task
}
}

/**
* Display the checkpoints
*/
void display_checkpoints()
{
for(int i = 0; i < checkpoints.size(); i++)
display_checkpoint(checkpoints.get(i));
}

/**
* Display a specific checkpoint
* @param checkpoint: the position of the checkpoint
*/
void display_checkpoint(Pos checkpoint)
{
pushMatrix();
translate(checkpoint.x, checkpoint.y, 0);
fill(0, 0, 0, 125);
fill(255, 255, 255, 125);
rectMode(CENTER);
rect(0, 0, 10, 10);
rect(0, 0, 20, 20);
popMatrix();
text(this.id, checkpoint.x - 9, checkpoint.y + 11);
}

/**
* An abstract method that will simulate the completion of the task
*/
abstract void do_task();
}
3 changes: 3 additions & 0 deletions strategy/TopLidar.pde
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* The top lidar (to detect the completion of tasks)
*/
class TopLidar extends Sensor
{
/**
Expand Down
16 changes: 15 additions & 1 deletion strategy/Weathercock.pde
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
/**
* This class represent the task weathercock
*/
class Weathercock extends Task
{
/* The begining of the task */
int weathercock_wait;

/**
* The constructor of Weathercock
* @param id: the identifier of the task
* @param points: the points given by the task
* @param position: the location of this task
* @param max_time: the estimated necessary time to accomplish the task
* @param weathercock_checkpoints: the checkpoints we need to reach to accomplish the task
*/
Weathercock(int id, int points, Pos position, long max_time, ArrayList<Pos> weathercock_checkpoints)
{
super(id, points, position, max_time);
Expand All @@ -27,7 +39,9 @@ class Weathercock extends Task
}
}


/**
* Simulate the execution of the weathercock
*/
void do_task()
{
this.in_progress();
Expand Down
11 changes: 11 additions & 0 deletions strategy/Windsock.pde
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
/**
* This class represent the task inked to the windocks
*/
class Windsock extends Task
{
/* The beginning of the task */
long windsock_wait;

Windsock(int id, int points, Pos position, long max_time, ArrayList<Pos> windsock_checkpoints)
Expand All @@ -9,6 +13,10 @@ class Windsock extends Task
this.windsock_wait = -1;
}

/**
* A function that windsock to be raised
* @return a boolean that indicate if the windsock is raised
*/
boolean raise_windsock()
{
if(windsock_wait == -1)
Expand All @@ -17,6 +25,9 @@ class Windsock extends Task
return (millis() - windsock_wait > 4000);
}

/**
* Simulate the execution of the windsock task
*/
void do_task()
{
this.in_progress();
Expand Down
14 changes: 13 additions & 1 deletion strategy/strategy.pde
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ float mod2Pi(float angle)
return angle;
}

/**
* Initialise sensors
* @return an ArrayList of sensors
*/
ArrayList<Sensor> init_sensors()
{
BottomLidar bottomLidar = new BottomLidar();
Expand All @@ -97,6 +101,9 @@ ArrayList<Sensor> init_sensors()
return sensors;
}

/**
* Manage the opponent behavement
*/
void manage_robot_op()
{
rob_op.update_destinations();
Expand Down Expand Up @@ -143,6 +150,9 @@ void init_robots()
POS_CUPS = new Pos(ARENA_HEIGHT/2, ARENA_WIDTH/2);
}

/**
* Initialize the tasks
*/
void init_tasks()
{
strat.tasks_order.add(TASK_LIGHTHOUSE);
Expand Down Expand Up @@ -190,7 +200,6 @@ void setup()
frameRate(fps);

init_robots();



dectable_lidar_mobile.add(POS_LIGHTHOUSE);
Expand Down Expand Up @@ -228,6 +237,9 @@ void display_infos()
text(strat.score, 1450, 21);
}

/**
* Manage the robot displayment
*/
void display_robot()
{
robot_RTS.getCorners();
Expand Down

0 comments on commit 7cb5162

Please sign in to comment.