Browse Source

Merge branch 'sarl' of git.libskia.so:skia/VI51 into sarl

sarl
smagnin 3 years ago
parent
commit
d74734b41d
3 changed files with 19 additions and 15 deletions
  1. +14
    -8
      rapport.tex
  2. +3
    -5
      src/main/sarl/fr/utbm/info/vi51/eurock/agent/guy.sarl
  3. +2
    -2
      src/main/sarl/fr/utbm/info/vi51/eurock/environment/WorldModel.java

+ 14
- 8
rapport.tex View File

@@ -119,13 +119,19 @@ the GUI.
return l;
}
\end{verbatim}
We add all the objects and not just agent bodies like at the origin.
\paragraph{}Bars red, and toilets green.
Concerning the scenes, there is one main stage in green, and two second stage
(black or pink). The two second stages switch between pink or black colour
regurlaly. It shows the kind of music they play.
Agents are
little circle (pink or black depending of what kind of music they like) with a line to see their direction.
We added all the objects on the screen and not just agent bodies, and we also added all this static objects to the view
frustum of the agent, to simulate a "map" of the festival: everybody knows where the interesting points are.

\section{Two frustums}
\par
To improve the behaviours, we added a second perception frustum. We had so a "view frustum", and a "move frustum", which
allowed to loop quickly on a smaller list to handle the moving behaviours.
\par
It had to be defined at many levels of the simulator stack: in the agent body, then in the perception computation
function, the finally build an updated Percept object that could contains both list. At the end, the agents could
iterate on one or the other, considering what had to be done (moving or taking decisions).

\section{Musical tastes of the agents}
There are two kinds of agent body :
\begin{itemize}
\item{One black, who listen metal music}
@@ -134,7 +140,7 @@ There are two kinds of agent body :
Following this they will be attract by the scene of the same style (or the green
scene, which is neutral and attract all agents).\\
At the beginning of the program all agents appears randomly in one of the four
corners of the map.
corners of the map, and then decides to do something.
\section{Avoid collisions}
To avoid collisions, we had to implement a function to get the nearest point
between a circle (agent) and a rectangle (bars, scenes, toilets)

+ 3
- 5
src/main/sarl/fr/utbm/info/vi51/eurock/agent/guy.sarl View File

@@ -109,7 +109,6 @@ agent Guy extends AbstractAnimat {
}

on PerceptionEvent {
// info("guy: " + (id == occurrence.body.bodyID))
this.id = occurrence.body.bodyID
// Handle actions
if (move_state == MoveState.WANDER) {
@@ -149,7 +148,7 @@ agent Guy extends AbstractAnimat {
var r = random.nextInt(100)
if (r < 0.05 * drunkness + 2) {
state = State.NEED_PEE
} else if (r < 15 + 0.2 * drunkness) {
} else if (r < 25 + 0.2 * drunkness) {
state = State.NEED_DRINK
} else {
state = State.NEED_MUSIC
@@ -309,7 +308,7 @@ agent Guy extends AbstractAnimat {
if (o.type == "GUY") {
// attraction += o.position - body.position
// direction += o.direction
repulsion += (body.position - o.position) / (((body.position - o.position).length ** 0.7 + 1) as float)
repulsion += (body.position - o.position) / (((body.position - o.position).length ** 0.6 + 1) as float)
} else if (o.type != "TARGET") {
var s = o.shape as Rectangle2f
var pt = s.getNearestPointFrom(body.position)
@@ -319,8 +318,7 @@ agent Guy extends AbstractAnimat {
}
}
attraction += (target - body.position)
attraction *= 6 / attraction.length
// attraction /= 2
attraction *= 10 / attraction.length
attraction *= (1.0 / (occ.movePerceptions.size + 1)) as float
direction += (target - body.position)
direction += attraction

+ 2
- 2
src/main/sarl/fr/utbm/info/vi51/eurock/environment/WorldModel.java View File

@@ -75,8 +75,8 @@ public class WorldModel extends AbstractEnvironment implements WorldModelStatePr
super(width, height, new StepTimeManager(500));
this.mainStage = new StageObject(150, 0, 200, 100);
this.smallStage1 = new StageObject(width-50, height/2, 50, 100);
this.smallStage2 = new StageObject(0, height-200, 50, 100);
this.toilets1 = new WCObject(450, 100, 10, 10);
this.smallStage2 = new StageObject(0, height/2, 50, 100);
this.toilets1 = new WCObject(400, 450, 10, 10);
this.toilets2 = new WCObject(30, 100, 10, 10);
this.bar1 = new BarObject(300, 200, 20, 20);
this.bar2 = new BarObject(250, 400, 20, 20);

Loading…
Cancel
Save