RouteLogic module

class RouteLogic.RouteLogic(width, height, in_out_pos, conveyor, inserter, assembler, recipe)[source]

Bases: DirectionalElement, GridElement, RecipeElement

This class contains the logic related with how elements interconnect between each other creating routes.

Parameters:
  • width (Int) – Width of the blueprint

  • height (Int) – Height of the blueprint

  • in_out_pos (Dictionary) – Contains the input and output positions and type of item carrying

  • conveyor (Array[Array] EnumSort) – Reference to the conveyor directions variable

  • inserter (Array[Array] EnumSort) – Reference to the inserter directions variable

  • assembler (Array[Array] BitVec) – Reference to the assembler collision_area variable

  • recipe (Dictionary) – Contains the recipes that the assemblers in the blueprint will use, for each recipe it has a list of the items it requires and which rate in items/min needs and the outputting item and rate.

backward_consistency()[source]

Constraint encoding the backward property of a route. If a cell contains a conveyor, the 3 input cell must have at least one route value smaller. In the other hand if the cell contains an inserter the input cell must have a route value lower than the inserter if there is no assembler, if there is then the inserter route value is 0 (route start)

Returns:

the logic encoding the constant

Return type:

Array

constraints()[source]

Creates a list of all the constraints representing the logic of the class

Returns:

class constraints compacted in a single list

Return type:

Array

domain_constraint()[source]

Creates a constarint that forces the route variables to take values inside the self.domain variable

Returns:

the logic encoding the constant

Return type:

Array

forward_consistency()[source]

Constraint encoding the forward property of a route. If a cell contains a conveyor, the cell its pointing must have a greater route value. In the opther hand if the cell contains an inserter the cell its pointing, can have an assembler (route value 0) if there is not an assembler the route value of the cell the inserter is pointing will have a grater route value.

Returns:

the logic encoding the constant

Return type:

Array

part_of_route()[source]

If a cell is part of route, then a conveyor or an inserter must be there

Returns:

the logic encoding the constant

Return type:

Array

route_end()[source]

Each output cell must have a larger route value than 1, and it must be a conveyor

Returns:

the logic encoding the constant

Return type:

Array

route_length()[source]

Sums the number of cells that contain a route value greater than 0. Used as an optimization criteria

Returns:

sum of route > 0

Return type:

Array

route_start()[source]

Each input cell is the start of a route, and it must be a conveyor

Returns:

the logic encoding the constant

Return type:

Array