app.engine.base_strategy module

class app.engine.base_strategy.BaseStrategy(strategy_name=None, strategy_description=None, strategy_name_slug=None, strategy_version='0.0.1', variable_basic_points=1, variable_bonus_points=1)[source]

Bases: object

Base class for strategies, providing a framework for creating and managing

strategy configurations.

strategy_name

The name of the strategy.

Type:

str

strategy_description

A description of the strategy.

Type:

str

strategy_name_slug

A slugified version of the strategy name.

Type:

str

strategy_version

The version of the strategy.

Type:

str

variable_basic_points

The basic points variable for the strategy.

Type:

int

variable_bonus_points

The bonus points variable for the strategy.

Type:

int

hash_version

The hash of the calculate_points method for versioning.

Type:

str

debug

Flag to enable or disable debug printing.

Type:

bool

__init__(strategy_name=None, strategy_description=None, strategy_name_slug=None, strategy_version='0.0.1', variable_basic_points=1, variable_bonus_points=1)[source]

Initializes the BaseStrategy with the provided attributes.

Parameters:
  • strategy_name (str, optional) – The name of the strategy.

  • strategy_description (str, optional) – A description of the strategy.

  • strategy_name_slug (str, optional) – A slugified version of the strategy name.

  • strategy_version (str, optional) – The version of the strategy. Default is “0.0.1”.

  • variable_basic_points (int, optional) – The basic points variable for the strategy. Default is 1.

  • variable_bonus_points (int, optional) – The bonus points variable for the strategy. Default is 1.

debug_print(*args)[source]

Emits debug information if debug mode is enabled.

Parameters:

*args – The arguments to log.

get_strategy_id()[source]
Retrieves the strategy ID, which is the class name. This id is the

filename of the strategy.

Returns:

str – The strategy ID.

get_strategy_name()[source]

Retrieves the strategy name.

Returns:

str – The strategy name.

get_strategy_description()[source]

Retrieves the strategy description.

Returns:

str – The strategy description.

get_strategy_name_slug()[source]

Retrieves the slugified strategy name.

Returns:

str – The slugified strategy name.

get_strategy_version()[source]

Retrieves the strategy version.

Returns:

str – The strategy version.

get_variable_basic_points()[source]

Retrieves the basic points variable.

Returns:

int – The basic points variable.

get_variable_bonus_points()[source]

Retrieves the bonus points variable.

Returns:

int – The bonus points variable.

set_variables(new_variables)[source]

Sets multiple variables at once.

Parameters:

new_variables (dict) – A dictionary of variable names and values.

Returns:

list – A list of variable names that were changed.

get_variables()[source]

Retrieves all variables whose name starts with variable_.

Returns:

dict – A dictionary of variable names and their values.

get_variable(variable_name)[source]

Retrieves the value of a specific variable.

Parameters:

variable_name (str) – The name of the variable.

Returns:

The value of the variable if it exists, otherwise None.

set_variable(variable_name, variable_value)[source]

Sets the value of a specific variable.

Parameters:
  • variable_name (str) – The name of the variable.

  • variable_value – The new value of the variable.

Returns:

bool – True if the variable was set, otherwise False.

get_strategy()[source]
Retrieves the strategy details including name, description, slug,

version, and variables.

Returns:

dict – A dictionary containing the strategy details.

async calculate_points(data=None)[source]

Calculates the points for the strategy.

Returns:

int – The basic points variable.

simulate_strategy(data=None)[source]

Simulates the strategy for testing purposes.

Returns:

dict – A dictionary containing the simulated points.

generate_logic_graph(format='png')[source]

Generates a logic graph for the strategy.

Returns:

str – The logic graph as a string.