Objective function f(x),
Initialize the population of wolves, for
Define and initialize parameters:
= radius of the visual range
= step size by which a wolf moves at a time
= velocity factor of wolf
= a user-defined threshold [ ], that determines how frequently an enemy appears, so will the wolf escape
WHILE ( generations && stopping criteria not met)
FOR //for each wolf
Prey_new_food_initiatively ();
Generate_new_location ();
// check whether the next location suggested by the random number generator is new. If not, repeat
 generating random location.
IF && is better as
    moves towards // is at a better place than
    = Prey_new_food_passively ();
Generate_new_location ();
IF (rand () )
    rand () ; //escape to a new position farther than
Pseudocode 1: Pseudocode of WSA.