FinalModel.py
def update(frame_number):
    """Creating stopping condition for the animation to reach stopping stage

       The animation will carry on and update each frame as the agents move, 
       eat and interact with other agents in the environment. The animation
       will stop running when the random state of 0.1 is reached. And we have 
       print the stopping condition which is an image showing the condition of
       environment and also the agents after reaching the stopping condition
       """
    fig.clear()
    global carry_on #The global variable set before is passed here    
    #If it gets a random number mentioned it stops
    if random.random() < 0.1: #The random() function within the random module, 
                              #That generates float number betweer 0 and 1. 
            carry_on = False
            print("stopping condition") #Prints the final condition of the environment
            
            
    #Agents behaviour, movement eating and sharing condtion set  
    for j in range(num_of_iterations):#Move the agent number of iteration time
     for i in range(num_of_agents):
        agents[i].move()
        agents[i].eat()
        agents[i].share_with_neighbours(neighbourhood)
        


    #Create plot of agents in environment      
    matplotlib.pyplot.xlim(0, 99) #Set the x-axis, i.e, it will go from 0 to 99
    matplotlib.pyplot.ylim(0, 99) #Set the y-axis, from 0 to 99
    matplotlib.pyplot.imshow(environment) #Display the image of environment
    for i in range(num_of_agents):
        matplotlib.pyplot.scatter(agents[i].x,agents[i].y)
Creating stopping condition for the animation to reach stopping stage

       The animation will carry on and update each frame as the agents move, 
       eat and interact with other agents in the environment. The animation
       will stop running when the random state of 0.1 is reached. And we have 
       print the stopping condition which is an image showing the condition of
       environment and also the agents after reaching the stopping condition
       
Creating stopping condition for the animation to reach stopping stage
The animation will carry on and update each frame as the agents move,
eat and interact with other agents in the environment. The animation
will stop running when the random state of 0.1 is reached. And we have
print the stopping condition which is an image showing the condition of
environment and also the agents after reaching the stopping condition
Creating stopping condition for the animation to reach stopping stage The animation will carry on and update each frame as the agents move eat and interact with other agents in the environment . The animation will stop running when the random state of 0 . 1 is reached . And we have print the stopping condition which is an image showing the condition of environment and also the agents after reaching the stopping condition
def update(frame_number):
    fig.clear()
    global carry_on 
    if random.random() < 0.1: 
            carry_on = False
            print("stopping condition") 
    for j in range(num_of_iterations):
     for i in range(num_of_agents):
        agents[i].move()
        agents[i].eat()
        agents[i].share_with_neighbours(neighbourhood)
    matplotlib.pyplot.xlim(0, 99) 
    matplotlib.pyplot.ylim(0, 99) 
    matplotlib.pyplot.imshow(environment) 
    for i in range(num_of_agents):
        matplotlib.pyplot.scatter(agents[i].x,agents[i].y)
def update ( frame_number ) : fig . clear ( ) global carry_on if random . random ( ) < 0.1 : carry_on = False print ( "stopping condition" ) for j in range ( num_of_iterations ) : for i in range ( num_of_agents ) : agents [ i ] . move ( ) agents [ i ] . eat ( ) agents [ i ] . share_with_neighbours ( neighbourhood ) matplotlib . pyplot . xlim ( 0 , 99 ) matplotlib . pyplot . ylim ( 0 , 99 ) matplotlib . pyplot . imshow ( environment ) for i in range ( num_of_agents ) : matplotlib . pyplot . scatter ( agents [ i ] . x , agents [ i ] . y )
Creating stopping condition for the animation to reach stopping stage
The animation will carry on and update each frame as the agents move,
eat and interact with other agents in the environment.
Creating stopping condition for the animation to reach stopping stage The animation will carry on and update each frame as the agents move eat and interact with other agents in the environment .
"""Creating stopping condition for the animation to reach stopping stage

       The animation will carry on and update each frame as the agents move, 
       eat and interact with other agents in the environment. The animation
       will stop running when the random state of 0.1 is reached. And we have 
       print the stopping condition which is an image showing the condition of
       environment and also the agents after reaching the stopping condition
       """ #The global variable set before is passed here     #If it gets a random number mentioned it stops #The random() function within the random module,  #That generates float number betweer 0 and 1.  #Prints the final condition of the environment #Agents behaviour, movement eating and sharing condtion set   #Move the agent number of iteration time #Create plot of agents in environment       #Set the x-axis, i.e, it will go from 0 to 99 #Set the y-axis, from 0 to 99 #Display the image of environment
frame_number