Agent Vision / Graphics

Last modification on 2019-04-03

Introduction

In ecosim's world each agent needs a method of understanding it's environment to be able to act intelligently. This information is provided by a "sensing" ability each agent posseses. Sensing is achieved by simply informaing each agent of any object (living or non-living) within a predefined radius around itself.

Whilst implementing this feature, debug code was written to give insight into what exactly the agents were sensing or "seeing". This can be see in Fig. 1 and Fig. 4. This debug code produced interesting visual effects, so it was built upon incrementally. Eventually this code evolved to the point where the decision to keep it as final version code was made.

Note:
In the time since the last update, basic AI was added to the agents. Each agent is randomly assigned an avoid/attract value. Agents with a value which is low avoid other agents at all cost, whilst agents who have a high value are attracted to other agents.

Stages

Stage 1: Implementation of Agent Vision

Fig1. Agent Vision

Here, agents are able to query the quadtree, then exclude any agents which sit outside of their vision field (represented by the red box). The number of agents in their vicinity is then printed.

Stage 2: Variable Agent Vision Scan Sizes

Fig 2. Variable vision sizes

Agents are given a variable vision size trait, which is randomized at birth.

Stage 3: Glowing Scan Visuals

Fig 3. Vision glow

The vision field has been changed from a GL_LINE_LOOP to a GL_QUADS with transparency. Agent count has been removed.

Stage 4: Variable Width Vision Lines

Fig 4. Variable width connection lines

Lines representing agents attraction / repulsion have been added, thicker lines represent a stronger sentiment.

Stage 5: Circular Scan Visuals

Fig 5. Circular vision graphics

At this stage the decision was made to start experimenting with different ways to represent the vision field. Circular vision fields were added. They are implemented in the same way that agents are. A vertex buffer is generated at each frame, which is then passed to a shader, which then uses a distance field to convert the square GL_POINTS into a circle.

Stage 6: Glowing Scan Visuals

Fig 6. Circular vision glow

In an attempt to give the vision fields a glowing effect a shader effect is applied, using the GLSL length() function to generate variable transparency. (Note: This may not display well on some screens, as they opacity is very low)

Stage 7: Pseudo-3D Agents

Fig 7. Agent inner glow

In an attempt an attempt to prevent the agents from looking so flat, a pseudo-3D effect was applied to the agents bodies. This again uses the length() function.

Conclusion

In the beginning a visual representation of the agents vision field was never intended, nor the vision lines. However after experimenting I have decided to keep them in the final version. It adds visual complexity to the project, and in my opinion, is reminiscent of something biological such as DNA.

In the future I will be experimenting with my project a lot more. The decision has been made to follow the Ecosim specification far less, as in some ways it was stifling creativity.