You are on page 1of 12

See discussions, stats, and author profiles for this publication at: https://www.researchgate.

net/publication/282379016

Flocking behaviour of group movement in real strategy games

Article · February 2015


DOI: 10.1109/INFOS.2014.7036679

CITATIONS READS

0 2,423

3 authors, including:

Heba Fathy Hatem Ahmed Abd elkader


Benha University Menoufia University
1 PUBLICATION   0 CITATIONS    232 PUBLICATIONS   1,614 CITATIONS   

SEE PROFILE SEE PROFILE

Some of the authors of this publication are also working on these related projects:

Semantic Anonymity for Data Privacy Preserving View project

cloud computing security View project

All content following this page was uploaded by Hatem Ahmed Abd elkader on 06 March 2019.

The user has requested enhancement of the downloaded file.


Flocking Behaviour of Group Movement in Real
Strategy Games
Abstract— Flocking is a convenient method to simulate natural and intelligent group movement

in computer games. This paper investigates the path-finding using flocking of groups in real-time

strategy games manifested by the open source game Wargus. The proposed technique aims to

improve unit movement and decrease unit lose in real-time strategy games. This technique has been

applied in some situations that its measurements indicate performance improvement concerning unit

damage.

Keywords—Flocking; PathFinding; Unit Movement.

I. INTRODUCTION

One of the most commercial computer games is real-time strategy (RTS) game which is growing

part of the entertainment industry and simulations. The field of AI in RTS game has advanced

significantly since Michael Buro’s call for research in this area[1]. Sophisticated artificial intelligence

techniques mostly been investigated and integreted in RTS games which is the fittest platform for that

state-of-the-art. Its complex, challenging environment and the dynamic gaming world has been offered

to players make it most suitable to AI research. This genre deals with strategies and intelligent behavior

so that the use of Bio-inspired techniques(computational intelligence) that have been used in a lot of

other genres is very beneficial. Wargus [2] is an open-source clone of the RTS game Warcraft

II(Blizzard, 1995) which we use in the research. One of the important factors to winning such a game is

the way units move, because an intelligent moving behavior might reduce casualties of own units. One

approach to solve a couple of problems related to the movement of groups is ”Flocking”, a technique

introduced by Reynolds [3]. He describes an approach to simulate an animated flock of birds and their
motion. Pathfinding of units is calculated in the game engine using A* algorthim. This paper aims to

provide an investigation of flocking approach in unit movement in Wargus game, which is mentioned in

the following sections. Experiments investigating the behavior of the methods in detail are given in

Section IV. Section V concludes our work and gives suggestions for future research.

II. REAL TIME STRATEGY GAMES

Real Time Strategy (RTS) is a video game which is sub-genre of strategy game where a player plans

a series of actions against one ore more opponents to achieve victory, and where actions are executed in

real-time. The player needs to build an economy, gathering resources, building a base and military

power through training units and researching technologies. The player has a list of objectives to fulfill,

takes the role of commander, in charge of a number of units and can use any or all of the units he

commands to complete those objectives. The key to defeating enemies lies in strategically controlling

game resources. Visibility is usually limited to a small area around player-owned units because players

can only see the part of the map that has been explored which is referred to as the fog-of-war. Player

must also decide which units and structures to produce and which technologies to advance in order to

have access to the right composition of units at the right times. The group movement should be reliable

so the player that can perform effective management and control movement behaviors for a group of

units navigating to particular locations.

A. Wargus

Wargus game is settled in a fantasy medieval which runs on the Stratagus open-source gaming

engine. Figure 1 shows a screenshot of a typical Wargus map which is defined as two-dimensional

terrain (map) tiles.


Figure 1: Snapshot of an Wargus game

The player has to gather and manage resources in order to construct buildings, create units and to

research upgrades like using new unit abilities or improve other units. Units must be distributed to

accomplish different tasks such as scouting, defense and attack. Armies consist of footmen (melee),

archers (range) and gryphon riders (air). Players need to understand the geometry of the map to decide

where to place new buildings and to set defensive outposts. The player’s victory requires defeating their

opponents through destroying their army and base . When offensive units of two players meet, each

player require quick and reactive control of each of their units to maneuver opponent’s units and

buildings. Each unit and building has a property called hit-points (HP) stating the unit’s health. The HP

of the unit is decresed, while it is being attacked by by the damage value of the attacking weapon. If HP

reaches zero, the unit dies.

B. Pathfinding

PathFinding employed as the core of any AI movement system whose responsibility is finding a path

from any coordinate in the game world to another. It finds aseries of points that comprise a path from

some point to destination. AI pathfinder usually employs some sort of precomputed data structure like
to guide the movement and this could be just a within the game that the unit is allowed move to[4]. The

two most commonly employed algorithms for directed pathfinding in games are known as Dijkstra and

A* respectively. The idea of Dijkstra’s algorithm is to use the uniform cost strategy to find the optimal

path while the A* algorithm combines both strategies thereby minimizing the total path cost. A*

algorthim uses best-first search algorithm to find the least-cost path given an initial node and a goal

node[5], growing an exploration area from the root node until a solution is found. The path cost

between nodes is calculated by the distance plus an heuristic function. A* has a great improvement over

Dijkstra algorithm with the right heuristic and is more efficient. It returns optimal path and became the

backbone behind almost all pathfinding designs in computer games.

C. Movement in RTS Games

The player issues a command to a unit or units to move to a specific location, but the player does not

have the facility to specify the path to be taken. That is the game engine’s responsibility, which

calculates a path for the units to move to their destination. Thus pathfinding plays a central role in RTS

game. It is simply the process of moving the position of a game character from its initial location to a

desired destination. In real-time environments, there may not be sufficient time to calculate the best

path for the units to be moved to their goal. There is the optimal path to onsider regardless of time

requirements, which leads to periods of delay in the game cycle. Although this delay allows optimal

path calculation to be completed[6]. There is also to compromise the quality of the path in the interest

of saving time, which allows RTS to be more responsive to the player’s commands. Flocking has an

opportunity to address this problem.


III. FLOCKING

Artifical(nonplayer) characters move in cohesive groups rather than moving independently.

Flocking is a popular tool for providing navigation for these characters. Flocking is appropriate method

proposed by Reynolds[3] to simulate natural group movement in computer games of e.g. swarms of

birds, schools of fishes, military units, or crowds[7]. Shen and Zhou [8] describe the use of flocking to

steer the behavior of military units in the futuristic ego-shooter unreal tournament. Davison [9]

mentions the use of flocking to control the movement of military units or to coordinate the formation of

any units in the ego-shooter Half-Life. The flocking behavior could be simulated by using three

principles, which were separation, alignment, and cohesion:

 Separation: Pushes units(boids) apart by maintaining distance from nearby flock mates. Each boid

considers its distance to other flock boids in its neighborhood and applies a repulsive force in the

opposite direction, scaled by the inverse of the distance. It represents the collision avoidance

within the flock.

 Cohesion: Keeps boids together as a group and eeach boid moves in the direction of the centroid

position of its neighbors. Compute the direction to the average position of the flock mates and

steer in that direction.

 Alignment: Drives boids to head in the same direction with similar velocities and calculate average

velocity of flock mates in neighborhood and steer towards that velocity.

These principles(rules) are represented in figure 2.


Seperation Cohesion Alignment

Figure 2: Schematic diagram of the three flocking rules


Red refers to Direction vector

A. Equations

The location of a boid’s neighbors, the directions, the neighbors are heading, and their distance to the

original boid are needed for implementing flocking principles.The units which player wants to move are

grouped in a flock and the path is caculated by using A* algorthim. The final direction v of a boid’s

movement is calculated as the weighted sum of the results of these three principles as follows:

where vref is the reference vector reflecting the direction of the calculated flock path, vcoh = posavg −

posunit is the vector from the units position to the average position of the flock, and vsep is the

separation vector. The corresponding weights are wref , wcoh, and wsep and the length of the separation

vector |vsep| is known to as SeparationDistance. Flocking depends on a number of parameters that

influence the behavior of every unit of a flock. For more information on the current implementation we

refer to the technical report of the project group 511 [10].

B. Seek and Flee

Seek tries to match the position of the player’s character with the position of the target. It finds the

direction to the target and heads fast toward it.


Figure 3: Seek and Flee

The steering output is an acceleration, it will accelerate as much as possible. It keeps on accelerating, its

speed will grow larger and larger. Most characters have a maximum speed they can travel and they

can’t accelerate indefinitely. In Appling seek and flee in wargus, the maximum is held in a variable or

constant. Seek and Flee is shown on figure 3. Seek (or pursuit of a static target) acts to steer the

character towards a specified position in global space and adjusts it so that its velocity is radially

aligned towards the target. Note that this is different from an attractive force (such as gravity) which

would produce an orbital path around the target point. The vector in the direction from the character to

the target is called desired velocity. The length of “desired velocity” could be max_speed or character’s

current speed, depending on the particular application. The steering vector is the difference between this

desired velocity and the character’s current velocity.

desired_velocity = normalize (position - target) * max_speed

steering = desired_velocity - velocity

If a character continues to seek, it will eventually pass through the target, and then turn back to

approach it again continuing to produces motion a bit like a moth buzzing around a light bulb.

Flee is simply the inverse of seek and acts to steer the character so that its velocity is radially aligned

away from the target. The desired velocity points in the opposite direction.
IV. EXPERIMENTAL EVALUATION

The experiments shall demonstrate advantages and drawbacks of the flocking techniques in RTS

games. We consider two different maps and observe the desired behaviors alignment, cohesion, and

separation for each group of units. In this experiment, the flocking is studied in comparison to the

normal group behavior to get an impression of the performance of this technique. We investigate the

properties of flocking by analyzing the performance of a group of combat units. We demonstrate that

flocking behaviour either improves or worsens the performance of a group compared to a normal group

behavior. We measure the performance of the group by counting the number of lost combat units, as

well as by calculating the lost overall hit-points of the combat units.

The set of tests includes a variety of maps, units and destinations. It tests log the elapsed time for each

cycle in the navigation engine. Instead of using several different maps, a single map reproduced to

several different scales are used to test the playability limits of the engine. Each scaled map is tested

with a different number of units to further determine the capabilities of the engine. The elapsed time is

measured for each cycle in the navigation engine.

Map1 Map2

Start Point End Point

Figure 4: Maps for the 2 scenarios

tested.
A. Setup

Using defensive tower in both maps and the map is rather small (64x64 tiles). River exist on map1

and a wall on map2 on units’ way to the goal as shown in figure 4. The units have to pass along defense

tower to get to their destination. The group used consists of six units with different abilities and

different average speed, combat strength, short-ranged and HP as listed in table 1.

TABLE I. SETUP PROPERITIES

Map Race Type Type of Units

Two catapult (average speed, average combat strength,


high-ranged, 110 HP), two troll axethrower (fast speed,
Map 1 ORC average combat strength, mid-ranged, 40 HP), and two
ogre(fast speed, low combat strength, low-ranged, 90
HP).
Two footman(fast speed, average combat strength, mid-
ranged, 60 HP), two archers (fast speed, average combat
Map 2 Human strength, mid-ranged, 40 HP), one dwarves (fast speed,
low combat strength, low-ranged, 40 HP), and one knight
(fast speed, low combat strength, average-ranged, 150
HP).

B. Experiment

The chosen parameter settings regarding this scenario are: SeparationWeight= 1.5, and

SeparationDistance = 10. The results in table 2 show the corresponding numbers of elasped time

calculated in seconds along with the number of game cycles and hit-points at the end of each scenario.

This measurment numbers is taken after unit reached their destination received on map one and map

two from above with normal movement and flocking behaviour. The test is done twice for the same

scenario and HP is measured by overall hit-points of the combat units.


TABLE II. EXPERIMENT SCENARIOS

Map Behaviour Game Cycles Elasped Time in Seconds HP

Map1 Normal 1440 2.909740 232

Map1 Flocking 1261 2.469886 247

Map1 Normal 1796 3.285428 196

Map1 Flocking 1417 2.559450 211

Map2 Normal 657 1.187260 150

Map2 Flocking 676 1.446849 160

Map2 Normal 535 1.120271 154

Map2 Flocking 414 0.833377 191

The mesurements illustrates the slight difference in time between the normal and applied flocking

behaviour in the game engine. In map 1 where there is an obstacle like the river, flocking is more

efficient in time and in keeping the units alive. Without flocking fast units break away from the slower

ones and the group splits, the units reach their destination with long delays. This experminent shows

that flocking behaviour is more efficient on keeping HP and saving unit strength. The flocking

behaviour improves the performance of the units in many game situation.

V. CONCLUSION

In this paper we have presented and evaluated the implementation of Flocking behaviour in group

movement for real-time strategy games, which is part of our long term goal of developing AI techniques

capable of handling large scale real-time domains. Our experiments show the impact that incorporating

effective moves like flocking can have in the performance. As part of our future work, we would like to
built on top of our approach and explore more complex tactical moves which may require require

explicit unit cooperation.

VI. REFERENCES

[1] M. Buro, “Real-time strategy games: A new ai research challenge,” in IJCAI 2003, International Joint Conferences on
Artificial Intelligence, 2003, pp. 1534–1535.
[2] The Wargus Team (2011) http://wargus.sourceforge.net/[Online].
[3] W. Reynolds, “Flocks, herds and schools: A distributed behavioral model,” in SIGGRAPH ’87: Proceedings of the 14th
annual conference on Computer graphics and interactive techniques, ACM, 1987, pp. 25–34.
[4] J.P.Schneider, ”Cohesive obstacle management for directed flocking in real-time strategy games”, Masters Abstracts
International, Volume: 43-05, page: 1756, 2004.
[5] R. Graham, H. Mccabe, and S. Sheridan, “Pathfinding in computer games”, ITB Journal Issue Number, 8:57–81, 2003.
[6] A. Pérez and S. Villar, “Multi-Reactive Planning for Real-Time Strategy Games”, Master’s thesis, Universitat Autonòma de
Barcelona, 2011.
[7] H. Danielsiek, R. Stüer, A. Thorm, N. Beume, B. Naujoks, and M.Preuss, “Intelligent moving of groups in real-time strategy
games,” in Proc. IEEE Symp. Comput. Intell. Games, L. Barone and P. Hingston, Eds., Piscataway, NJ, 2008, pp. 71–78.
[8] Z. Shen and S. Zhou, “Behavior representation and simulation for military operations on urbanized terrain,” Simulation, vol.
82, no. 9,pp. 593–607, 2006.
[9] A. Davison, Killer Game Programming in Java. O’Reilly Media, Inc., 2005.
[10] H. Danielsiek, C. Eichhorn, T. Hein, E. Kurti´c, G. Neugebauer, N. Piatkowski, J. Quadflieg, S. Schnelker, R. St¨uer, A.
Thom, and S. Wessing, “Final report of PG 511,” Technische Universit¨at Dortmund, Technical Report of the Collaborative
Research Centre 531 Computational Intelligence Reihe CI 252/08, SFB 531, 2008. Available:
http://www.ciingames.de/publications/pg511finalreport.pdf[Online].

View publication stats

You might also like