pNeuma_simulator.shadowcasting.fov module

class pNeuma_simulator.shadowcasting.fov.FoV(df, origin)[source]

Bases: object

A class to represent the Field of View (FoV) for a given map.

is_visible

A set to store the coordinates of visible tiles.

Type:

set

map_str

A string representation of the map where ‘#’ represents a wall and ‘.’ represents a floor.

Type:

str

map_lis

A list of strings where each string is a row of the map.

Type:

list

origin

The origin point (x, y) from which the FoV is calculated.

Type:

tuple

compute_fov()[source]
is_blocking(x, y)[source]
mark_visible(x, y)[source]
class pNeuma_simulator.shadowcasting.fov.Quadrant(cardinal, origin)[source]

Bases: object

Represents a quadrant in a field of view (FOV) algorithm.

The Quadrant class is used to transform tile coordinates based on the cardinal direction of the quadrant (north, east, south, or west).

cardinal

The cardinal direction of the quadrant.

Type:

int

ox

The x-coordinate of the origin.

Type:

int

oy

The y-coordinate of the origin.

Type:

int

east = 1

Constant representing the east direction.

Type:

(int)

north = 0

Constant representing the north direction.

Type:

(int)

south = 2

Constant representing the south direction.

Type:

(int)

transform(tile)[source]

Transforms tile coordinates based on the quadrant’s cardinal direction.

Parameters:

tile (tuple) – A tuple (row, col) representing the tile coordinates.

Returns:

Transformed tile coordinates (x, y).

Return type:

tuple

west = 3

Constant representing the west direction.

Type:

(int)

class pNeuma_simulator.shadowcasting.fov.Row(depth, start_slope, end_slope)[source]

Bases: object

Represents a row in a field of view (FOV) algorithm.

The Row class is used to manage the start and end slopes of a row of tiles being scanned in the FOV algorithm.

depth

The depth of the row.

Type:

int

start_slope

The starting slope of the row.

Type:

Fraction

end_slope

The ending slope of the row.

Type:

Fraction

next()[source]

Generates the next row in the FOV algorithm.

Returns:

The next row with incremented depth and the same slopes.

Return type:

Row

round_ties_down(n)[source]
round_ties_up(n)[source]
tiles()[source]