Professional Documents
Culture Documents
Clash of Clans Particle Swarm Optimizer 1703429024
Clash of Clans Particle Swarm Optimizer 1703429024
Abstract— This research introduces a novel metaheuristic of each particle in the swarm is affected both by the local best
optimization method inspired by Particle Swarm Optimization solution during its search (individual) and the position of the
(PSO) and tailored to the dynamics of the popular video game global best particle in its surrounding (trajectory) [2].
Clash of Clans. The proposed Clash of Clans Optimizer utilizes A widely used foundation for other optimizers, PSO
diverse troop types with unique characteristics, presenting a
dynamic balance between exploration and exploitation in multi-
is an attractive solution due to its ease of initialization and
dimensional search applications. Despite a slower runtime particle parameter tuning, yet one of the inherent limitations
compared to traditional PSO, our algorithm demonstrates the with PSO is a premature convergence to local optimum points
ability to identify better global optimums, showcasing its of the objective landscape. To mitigate these shortcomings,
effectiveness. The algorithm's tunability is highlighted through we propose a metaheuristic optimization method based on the
the adjustment of elixir amounts, allowing users to control the popular video game, Clash of Clans [3]. Particles are
number of troops generated and customize the optimization represented through diverse troops and characters, each of
process. Moreover, the concept of hard-coding troop which possess unique capabilities and behaviour patterns.
compositions is introduced as a potential enhancement, Swarm initialization consists of allocating troops to specific
providing a strategic approach to team generation. The results
suggest that the Clash of Clans Optimizer presents a promising
regions of the optimization landscape based on ability and
alternative for optimization scenarios, addressing the strategic considerations. Through the assignment of fitness
limitations of premature convergence often associated with scores each iteration (referred to as a ‘raid’ in the algorithm)
PSO. This study opens avenues for further exploration and on a one-to-three-star scale, a feedback loop is introduced by
refinement of this innovative optimization approach. which future raid decisions are derived. Each raid iteration
consists of a troop attack on its neighbours, following a
Keywords—PSO, optimization, clash of clans, metaheuristic Variable Neighborhood Search approach.
search
©2023 IEEE
A. Troop Design neighborhoods containing the top three lowest found costs are
To create a dynamic balance between the amount of assigned a star ranking whereby the global best solution of
exploration across the optimization landscape and the iteration is awarded three stars, the second best
exploitation of local results, six particle objects, or troops, are performing receives two stars, and the third neighborhood
defined and initialized with characteristic member attributes one star- to then inform the next raid iteration. These top-
from a base particle class. Characteristics have been selected scoring neighborhoods are then passed as input arguments to
and expressed through weights, or hyperparameters to either the next iterations of the algorithm.
augment or decrease the velocity of each particle. As such, The neighborhood generation involves two integral
𝛼1 denotes the weight on the momentum component, or components. Firstly, a function is introduced to partition a
overall particle speed, 𝛼2 weighs the local best solution, and given numerical range into distinct sets. Given a start and end
determines how much to exploit the landscape, and 𝛼3 point of a range, as well as the desired number of sets, the
weighs the global best solution velocity component, and thus function calculates the size of each subinterval and iteratively
how much to explore the landscape [1]. computes the start and end points for each set. The resulting
Additionally, for the control of the proportion of each sets are represented as tuples and collectively form a division
troop type to initialize in an iteration of raids, an “elixir” of the original range. This function provides a foundational
hyperparameter is introduced. Elixir determines the mechanism for discretizing continuous numerical domains.
program’s total capacity for how many troops, or particles The neighborhood generation function leverages this to
will be implemented [3]. Each troop type is assigned an elixir construct neighborhoods within a two-dimensional region.
value in the range of 1-10 to control how many of each type Through nested loops, it combines the width and height
can be at play. This parameter can be adjusted depending on subintervals to generate a grid of neighborhoods, where each
a user’s preference for more exploration versus exploitation. neighborhood is represented by a list of width and height
subintervals. This configuration allows the partitioning of the
1. Giant: More inclined for exploitation techniques whole neighborhood into discrete rows and columns, yielding
during a raid iteration, giants are designed to move a structured grid-based neighborhood.
in a slower fashion through their local C. Troop Tuning
neighborhood. Thus, the particles are assigned small
alpha values in initialization. For our The 𝛼1,2,3 weights were then fine-tuned to mimic each
implementation purposes, they have been assigned troops assigned behaviour in the game, to thus iteratively
an average elixir value of five. update their velocity, as seen in Equation (1).
2. Archer: Archers offer a middle ground approach for
exploration versus exploitation. With a large weight 𝑇𝑜𝑡𝑎𝑙 𝑣𝑒𝑙𝑜𝑐𝑖𝑡𝑦 = 𝛼1 ∗ 𝑣𝑒𝑙𝑜𝑐𝑖𝑡𝑦 + 𝛼2 ∗ (𝑙𝑜𝑐𝑎𝑙𝑏𝑒𝑠𝑡 −
𝑝𝑜𝑠𝑖𝑡𝑖𝑜𝑛) + 𝛼3 ∗ (𝑔𝑙𝑜𝑏𝑎𝑙𝑏𝑒𝑠𝑡 − 𝑝𝑜𝑠𝑖𝑡𝑖𝑜𝑛 ()
on the local best velocity component, Archers have
the capacity to cover large distances towards self-
For visualization purposes of the tuning stage, the algorithm
identified targets. Relatively cheap at an elixir of
was run using one troop of the corresponding type, of which
three, many archers can be deployed at a time.
the results are shown below.
3. Goblin: With a tendency to quickly identify local
best solutions due to a large momentum weight,
1. Giant: The low alpha values represent the slow
goblin particle types face the challenge of becoming
behaviour of this troop as seen in Figure 1.
stuck in local bests, similar to a local treasure trove
in the video game. In this case, goblins are the
lowest cost character at an elixir value of two.
4. Wizard: Wizard troop types offer a balance through
mid-range weights on all velocity components. The
prescribed elixir value for this troop type is average
at a value of 4.
5. Dragon: Designed to mimic the character with a
long-range aerial view, the dragon is designed for
high exploration across the optimization landscape
through large weights on momentum, as well as Fig. 1. Optimization results for test with Giant hyperparameters.
local and global best solutions. A rare character,
dragons are deemed worth 10 elixir units. 2. Archer: A larger gain of alpha values were used
6. Hog Rider: Enabled with agility, the hog rider with emphasis on 𝛼2 to mimic the middle ground
particles can jump using large steps from iteration to approach of this troop as seen in Figure 2.
iteration yet employ a moderate speed through a
mid-range momentum weight within local search.
The given elixir for these particles is 6, slightly
above the middle ground.
B. Neighborhood Implementation
Another distinction from PSO concerns the best
neighborhood assignment in each iteration. In similar fashion
to the score assigned a raid in Clash of Clans, the
Fig. 2. Optimization results for test with Archer hyperparameters. Fig. 6. Optimization results with Hog Rider hyperparameters.
3. Goblin: A medium sized gain was used for the alpha From this setup, several well-known benchmark
values with emphasis on 𝛼1 due to the fast mobility cost functions have been defined for algorithm execution and
of this troop, which is represented in Figure 3. testing. For comparative analysis to similar metaheuristic
optimization methods, additional algorithms were selected to
run on the same cost function, convergence criteria, and
iterations, of which the final global best and runtime are
recorded. A plotting method to trace the path of the particles
has been included for ease of visualization.