Zappy - Year end project 2
This is a project that Epitech asked us to create in order to allow us to reveiw the notions of the current year.
Loading...
Searching...
No Matches
Public Member Functions | Data Fields | Protected Member Functions | Protected Attributes
logistics.Logistics Class Reference
Collaboration diagram for logistics.Logistics:
Collaboration graph

Public Member Functions

None __init__ (self, GlobalVariables global_variables)
 
int dispatcher (self, dict[Commands, any] response)
 

Data Fields

 global_variables
 
 client_number
 
 client_coordinates
 
 welcome_received
 
 initialisation_complete
 
 nb_responses
 
 tile_content
 
 random_seed
 
 sabotage
 
 direction_options_list
 
 direction_options
 
 client_number_received
 

Protected Member Functions

int _create_random_seed (self)
 
None _forward (self)
 
None _left (self)
 
None _right (self)
 
int _my_randint (self, int minimum=0, int maximum=3)
 
None _change_my_mind (self)
 
None _update_ai_status (self, int status)
 
int _process_welcome (self, str data)
 
int _process_client_number (self, str data)
 
int _process_map_dimensions (self, str data)
 
bool _can_evolve (self, str command)
 
int _exit_error (self, str string)
 
None _append_look_command (self)
 
str _to_human_readable (self, int code)
 
int _calculate_next_move (self, dict[Commands, any] response)
 

Protected Attributes

 _forward
 
 _left
 

Detailed Description

_summary_
This is the class in charge of containing the ai which provides a purpose for this program

Args:
    Thread (_type_): _description_: The class that is to be used in order to start threads

Definition at line 16 of file logistics.py.

Constructor & Destructor Documentation

◆ __init__()

None logistics.Logistics.__init__ ( self,
GlobalVariables global_variables )

Definition at line 24 of file logistics.py.

Member Function Documentation

◆ _append_look_command()

None logistics.Logistics._append_look_command ( self)
protected
_summary_
    This function appends the look command to the response buffer.

Definition at line 259 of file logistics.py.

◆ _calculate_next_move()

int logistics.Logistics._calculate_next_move ( self,
dict[Commands, any] response )
protected
_summary_
    This function will calculate the next move based on the response from the server.

Args:
    response (dict[Commands, any]): _description_: The query that came in from the tcp protocol.

Returns:
    int: _description_: The status of the execution.

Definition at line 285 of file logistics.py.

◆ _can_evolve()

bool logistics.Logistics._can_evolve ( self,
str command )
protected
_summary_
    This function checks if the ai can evolve.
Args:
    command (str | list): _description_: The content of the Look response

Returns:
    bool: _description_: Returns True if the ai can get to the next level, otherwise False is returned.

Definition at line 214 of file logistics.py.

◆ _change_my_mind()

None logistics.Logistics._change_my_mind ( self)
protected
_summary_
This function is the one in charge of creating a random movement

Definition at line 110 of file logistics.py.

◆ _create_random_seed()

int logistics.Logistics._create_random_seed ( self)
protected
_summary_
Generate a random seed
Returns:
    int: _description_

Definition at line 44 of file logistics.py.

◆ _exit_error()

int logistics.Logistics._exit_error ( self,
str string )
protected
_summary_
    This function should never be triggered in a normal use case.
    This function will send an error message and set the global status to self.global_variable.error
Returns:
    int: _description_: The error status defined in global_variables

Definition at line 246 of file logistics.py.

◆ _forward()

None logistics.Logistics._forward ( self)
protected
_summary_
    Add the forward command

Definition at line 55 of file logistics.py.

◆ _left()

None logistics.Logistics._left ( self)
protected
_summary_
    Add the left command

Definition at line 68 of file logistics.py.

◆ _my_randint()

int logistics.Logistics._my_randint ( self,
int minimum = 0,
int maximum = 3 )
protected
_summary_
    This is a function that will be used in order to provide a randome number without using the random library.

Definition at line 94 of file logistics.py.

◆ _process_client_number()

int logistics.Logistics._process_client_number ( self,
str data )
protected
_summary_
    This function will check if we have received the client number
Args:
    data (str): _description_: The incoming data

Returns:
    int: _description_: The status of the processed data

Definition at line 158 of file logistics.py.

◆ _process_map_dimensions()

int logistics.Logistics._process_map_dimensions ( self,
str data )
protected
_summary_
    This is a function that will make sure that the dimensions of the map.
Args:
    data (str): _description_

Returns:
    int: _description_

Definition at line 180 of file logistics.py.

◆ _process_welcome()

int logistics.Logistics._process_welcome ( self,
str data )
protected
_summary_
    This function will set the variables corresponding to the initialisation process
Returns:
    int: _description_: The processing status

Definition at line 135 of file logistics.py.

◆ _right()

None logistics.Logistics._right ( self)
protected
_summary_
    Add the right command

Definition at line 81 of file logistics.py.

◆ _to_human_readable()

str logistics.Logistics._to_human_readable ( self,
int code )
protected
_summary_
    Replace the code with the corresponding state.
Args:
    code (int): _description_: The corresponding code

Returns:
    str: _description_: The corresponding text that the human can understand

Definition at line 272 of file logistics.py.

◆ _update_ai_status()

None logistics.Logistics._update_ai_status ( self,
int status )
protected
_summary_
    This function works like a onetime valve, if one error ever gets raised, the variable will never go back to 0.
Args:
    status (int): _description_: the run status of the previous function

Definition at line 121 of file logistics.py.

◆ dispatcher()

int logistics.Logistics.dispatcher ( self,
dict[Commands, any] response )
_summary_

Args:
    response (str): _description_: The converted response

Returns:
    int: _description_: The status response of the program

Definition at line 343 of file logistics.py.

Field Documentation

◆ _forward

logistics.Logistics._forward
protected

Definition at line 39 of file logistics.py.

◆ _left

logistics.Logistics._left
protected

Definition at line 40 of file logistics.py.

◆ client_coordinates

logistics.Logistics.client_coordinates

Definition at line 28 of file logistics.py.

◆ client_number

logistics.Logistics.client_number

Definition at line 27 of file logistics.py.

◆ client_number_received

logistics.Logistics.client_number_received

Definition at line 177 of file logistics.py.

◆ direction_options

logistics.Logistics.direction_options

Definition at line 38 of file logistics.py.

◆ direction_options_list

logistics.Logistics.direction_options_list

Definition at line 37 of file logistics.py.

◆ global_variables

logistics.Logistics.global_variables

Definition at line 25 of file logistics.py.

◆ initialisation_complete

logistics.Logistics.initialisation_complete

Definition at line 31 of file logistics.py.

◆ nb_responses

logistics.Logistics.nb_responses

Definition at line 33 of file logistics.py.

◆ random_seed

logistics.Logistics.random_seed

Definition at line 35 of file logistics.py.

◆ sabotage

logistics.Logistics.sabotage

Definition at line 36 of file logistics.py.

◆ tile_content

logistics.Logistics.tile_content

Definition at line 34 of file logistics.py.

◆ welcome_received

logistics.Logistics.welcome_received

Definition at line 29 of file logistics.py.


The documentation for this class was generated from the following file: