ogd.games.BLOOM.features package

Submodules

ogd.games.BLOOM.features.ActiveTime module

# import libraries from datetime import datetime, timedelta import logging, warnings from builtins import float from typing import Any, Final, List, Optional, Dict # import locals from ogd.common.utils.Logger import Logger from ogd.core.generators.Generator import GeneratorParameters from ogd.core.generators.extractors.Feature import Feature from ogd.common.models.Event import Event from ogd.common.models.enums.ExtractionMode import ExtractionMode from ogd.common.models.FeatureData import FeatureData

class ActiveTime(Feature):

IDLE_LEVEL: Final[int] = 30

def __init__(self, params: GeneratorParameters, active_threads: Optional[float] = None):

super().__init__(params=params) self._Idle_time: float = 0 self.active_level: float = active_threads if active_threads else ActiveTime.IDLE_LEVEL self._sess_duration: Optional[timedelta] = None self._client_start_time: Optional[datetime] = None self._client_end_time: Optional[datetime] = None

# * IMPLEMENT ABSTRACT FUNCTIONS * @classmethod def _eventFilter(cls, mode: ExtractionMode) -> List[str]:

return [“session_start”, “pause_game”, “unpause_game”]

@classmethod def _featureFilter(cls, mode: ExtractionMode) -> List[str]:

return []

def _updateFromEvent(self, event: Event) -> None:
if event.EventName == “session_start”:

self._client_start_time = event.Timestamp

elif event.EventName == “pause_game”:

self._client_end_time = event.Timestamp

elif event.EventName == “unpause_game”:

self._client_start_time = event.Timestamp

def _updateFromFeatureData(self, feature: FeatureData):

return

def _getFeatureValues(self) -> List[Any]:
if self._client_start_time and self._client_end_time:

return [self._client_end_time - self._client_start_time - timedelta(seconds=self._Idle_time)]

else:

return [“No events”]

# * Optionally override public functions. * @staticmethod def MinVersion() -> Optional[str]:

return “1”

class ogd.games.BLOOM.features.ActiveTime.ActiveTime(params: GeneratorParameters, idle_threshold: int | None)[source]

Bases: Extractor

DEFAULT_IDLE_THRESHOLD: Final[timedelta] = datetime.timedelta(seconds=30)[source]
static MinVersion() str | None[source]
Base function to get the minimum log version the feature can handle.

A value of None will set no minimum, so all levels are accepted (unless a max is set). Typically default to None, unless there is a required element of the event data that was not added until a certain version. The versions of data accepted by a feature are a responsibility of the Feature’s developer, so this is a required part of interface instead of a config item in the schema.

Returns:

[description]

Return type:

Optional[str]

Subfeatures() List[str][source]

Base function to get a list of names of the sub-feature(s) a given Feature class outputs. By default, a Feature class has no subfeatures. However, if a Feature class is written to output multiple values, it will need to override this function to return an appropriate list. Note, Subfeatures must match the ordering from the override of GetFeatureNames, if returning a list of length > 0.

Returns:

A list of names of subfeatures for the Feature sub-class.

Return type:

Tuple[str]

ogd.games.BLOOM.features.AlertCount module

class ogd.games.BLOOM.features.AlertCount.AlertCount(params: GeneratorParameters)[source]

Bases: Extractor

static MinVersion() str | None[source]
Base function to get the minimum log version the feature can handle.

A value of None will set no minimum, so all levels are accepted (unless a max is set). Typically default to None, unless there is a required element of the event data that was not added until a certain version. The versions of data accepted by a feature are a responsibility of the Feature’s developer, so this is a required part of interface instead of a config item in the schema.

Returns:

[description]

Return type:

Optional[str]

Subfeatures() List[str][source]

Base function to get a list of names of the sub-feature(s) a given Feature class outputs. By default, a Feature class has no subfeatures. However, if a Feature class is written to output multiple values, it will need to override this function to return an appropriate list. Note, Subfeatures must match the ordering from the override of GetFeatureNames, if returning a list of length > 0.

Returns:

A list of names of subfeatures for the Feature sub-class.

Return type:

Tuple[str]

ogd.games.BLOOM.features.AlertReviewCount module

class ogd.games.BLOOM.features.AlertReviewCount.AlertReviewCount(params: GeneratorParameters)[source]

Bases: Extractor

static MinVersion() str | None[source]
Base function to get the minimum log version the feature can handle.

A value of None will set no minimum, so all levels are accepted (unless a max is set). Typically default to None, unless there is a required element of the event data that was not added until a certain version. The versions of data accepted by a feature are a responsibility of the Feature’s developer, so this is a required part of interface instead of a config item in the schema.

Returns:

[description]

Return type:

Optional[str]

Subfeatures() List[str][source]

Base function to get a list of names of the sub-feature(s) a given Feature class outputs. By default, a Feature class has no subfeatures. However, if a Feature class is written to output multiple values, it will need to override this function to return an appropriate list. Note, Subfeatures must match the ordering from the override of GetFeatureNames, if returning a list of length > 0.

Returns:

A list of names of subfeatures for the Feature sub-class.

Return type:

Tuple[str]

ogd.games.BLOOM.features.AverageActiveTime module

# import libraries from datetime import timedelta from typing import Any, Dict, List, Optional from ogd.core.generators.Generator import GeneratorParameters from ogd.core.generators.extractors.Feature import Feature from ogd.common.models.Event import Event from ogd.common.models.enums.ExtractionMode import ExtractionMode from ogd.common.models.FeatureData import FeatureData

class AverageActiveTime(Feature):
def __init__(self, params: GeneratorParameters):

super().__init__(params=params) self.active_time_per_session: Dict[str, timedelta] = {} self.session_count: Dict[str, int] = {}

# * IMPLEMENT ABSTRACT FUNCTIONS * @classmethod def _eventFilter(cls, mode: ExtractionMode) -> List[str]:

return [“session_start”, “pause_game”, “unpause_game”]

@classmethod def _featureFilter(cls, mode: ExtractionMode) -> List[str]:

return [“ActiveTime”, “NumberOfSessionsPerPlayer”]

def _updateFromEvent(self, event: Event) -> None:
if event.EventName == “session_start”:

player_id = event.PlayerID self.session_count[player_id] = self.session_count.get(player_id, 0) + 1

elif event.EventName == “pause_game”:

player_id = event.PlayerID self.active_time_per_session[player_id] = self.active_time_per_session.get(player_id, timedelta()) self.active_time_per_session[player_id] -= event.Timestamp

elif event.EventName == “unpause_game”:

player_id = event.PlayerID self.active_time_per_session[player_id] = self.active_time_per_session.get(player_id, timedelta()) self.active_time_per_session[player_id] += event.Timestamp

def _updateFromFeatureData(self, feature: FeatureData):
if feature.Name == “ActiveTime”:

self.active_time_per_session = feature.Value

elif feature.Name == “NumberOfSessionsPerPlayer”:

self.session_count = feature.Value

def _getFeatureValues(self) -> List[Any]:

average_active_time = {} for player_id, active_time in self.active_time_per_session.items():

session_count = self.session_count.get(player_id, 0) if session_count != 0:

average_active_time[player_id] = active_time / session_count

return [average_active_time]

# * Optionally override public functions. * @staticmethod def MinVersion() -> Optional[str]:

return “1”

class ogd.games.BLOOM.features.AverageActiveTime.AverageActiveTime(params: GeneratorParameters)[source]

Bases: Extractor

static MinVersion() str | None[source]
Base function to get the minimum log version the feature can handle.

A value of None will set no minimum, so all levels are accepted (unless a max is set). Typically default to None, unless there is a required element of the event data that was not added until a certain version. The versions of data accepted by a feature are a responsibility of the Feature’s developer, so this is a required part of interface instead of a config item in the schema.

Returns:

[description]

Return type:

Optional[str]

ogd.games.BLOOM.features.BloomAlertCount module

class ogd.games.BLOOM.features.BloomAlertCount.BloomAlertCount(params: GeneratorParameters)[source]

Bases: Extractor

Subfeatures() List[str][source]

Base function to get a list of names of the sub-feature(s) a given Feature class outputs. By default, a Feature class has no subfeatures. However, if a Feature class is written to output multiple values, it will need to override this function to return an appropriate list. Note, Subfeatures must match the ordering from the override of GetFeatureNames, if returning a list of length > 0.

Returns:

A list of names of subfeatures for the Feature sub-class.

Return type:

Tuple[str]

ogd.games.BLOOM.features.BuildCount module

class ogd.games.BLOOM.features.BuildCount.BuildCount(params: GeneratorParameters)[source]

Bases: Extractor

Subfeatures() List[str][source]

Base function to get a list of names of the sub-feature(s) a given Feature class outputs. By default, a Feature class has no subfeatures. However, if a Feature class is written to output multiple values, it will need to override this function to return an appropriate list. Note, Subfeatures must match the ordering from the override of GetFeatureNames, if returning a list of length > 0.

Returns:

A list of names of subfeatures for the Feature sub-class.

Return type:

Tuple[str]

ogd.games.BLOOM.features.BuildingUnlockCount module

class ogd.games.BLOOM.features.BuildingUnlockCount.BuildingUnlockCount(params: GeneratorParameters)[source]

Bases: Extractor

static MinVersion() str | None[source]
Base function to get the minimum log version the feature can handle.

A value of None will set no minimum, so all levels are accepted (unless a max is set). Typically default to None, unless there is a required element of the event data that was not added until a certain version. The versions of data accepted by a feature are a responsibility of the Feature’s developer, so this is a required part of interface instead of a config item in the schema.

Returns:

[description]

Return type:

Optional[str]

Subfeatures() List[str][source]

Base function to get a list of names of the sub-feature(s) a given Feature class outputs. By default, a Feature class has no subfeatures. However, if a Feature class is written to output multiple values, it will need to override this function to return an appropriate list. Note, Subfeatures must match the ordering from the override of GetFeatureNames, if returning a list of length > 0.

Returns:

A list of names of subfeatures for the Feature sub-class.

Return type:

Tuple[str]

ogd.games.BLOOM.features.CountyBloomAlertCount module

class ogd.games.BLOOM.features.CountyBloomAlertCount.CountyBloomAlertCount(params: GeneratorParameters)[source]

Bases: PerCountyFeature

static MinVersion() str | None[source]
Base function to get the minimum log version the feature can handle.

A value of None will set no minimum, so all levels are accepted (unless a max is set). Typically default to None, unless there is a required element of the event data that was not added until a certain version. The versions of data accepted by a feature are a responsibility of the Feature’s developer, so this is a required part of interface instead of a config item in the schema.

Returns:

[description]

Return type:

Optional[str]

Subfeatures() List[str][source]

Base function to get a list of names of the sub-feature(s) a given Feature class outputs. By default, a Feature class has no subfeatures. However, if a Feature class is written to output multiple values, it will need to override this function to return an appropriate list. Note, Subfeatures must match the ordering from the override of GetFeatureNames, if returning a list of length > 0.

Returns:

A list of names of subfeatures for the Feature sub-class.

Return type:

Tuple[str]

ogd.games.BLOOM.features.CountyBuildCount module

# import libraries from typing import Any, Dict, List, Optional from ogd.core.generators.Generator import GeneratorParameters from ogd.core.generators.extractors.Feature import Feature from ogd.common.models.Event import Event from ogd.common.models.enums.ExtractionMode import ExtractionMode from ogd.common.models.FeatureData import FeatureData

class CountyBuildCount(Feature):
def __init__(self, params: GeneratorParameters):

super().__init__(params=params) self.build_counts: Dict[str, int] = {}

# * IMPLEMENT ABSTRACT FUNCTIONS * @classmethod def _eventFilter(cls, mode: ExtractionMode) -> List[str]:

return [“execute_build_queue”]

@classmethod def _featureFilter(cls, mode: ExtractionMode) -> List[str]:

return []

def _updateFromEvent(self, event: Event) -> None:

county_name = event.EventData.get(“county_name”, None) if county_name:

if county_name not in self.build_counts:

self.build_counts[county_name] = 1

else:

self.build_counts[county_name] += 1

def _updateFromFeatureData(self, feature: FeatureData):

pass

def _getFeatureValues(self) -> List[Any]:

return [self.build_counts]

def Subfeatures(self) -> List[str]:

return []

class ogd.games.BLOOM.features.CountyBuildCount.CountyBuildCount(params: GeneratorParameters)[source]

Bases: PerCountyFeature

Subfeatures() List[str][source]

Base function to get a list of names of the sub-feature(s) a given Feature class outputs. By default, a Feature class has no subfeatures. However, if a Feature class is written to output multiple values, it will need to override this function to return an appropriate list. Note, Subfeatures must match the ordering from the override of GetFeatureNames, if returning a list of length > 0.

Returns:

A list of names of subfeatures for the Feature sub-class.

Return type:

Tuple[str]

ogd.games.BLOOM.features.CountyFailCount module

class ogd.games.BLOOM.features.CountyFailCount.CountyFailCount(params: GeneratorParameters)[source]

Bases: PerCountyFeature

static MinVersion() str | None[source]
Base function to get the minimum log version the feature can handle.

A value of None will set no minimum, so all levels are accepted (unless a max is set). Typically default to None, unless there is a required element of the event data that was not added until a certain version. The versions of data accepted by a feature are a responsibility of the Feature’s developer, so this is a required part of interface instead of a config item in the schema.

Returns:

[description]

Return type:

Optional[str]

Subfeatures() List[str][source]

Base function to get a list of names of the sub-feature(s) a given Feature class outputs. By default, a Feature class has no subfeatures. However, if a Feature class is written to output multiple values, it will need to override this function to return an appropriate list. Note, Subfeatures must match the ordering from the override of GetFeatureNames, if returning a list of length > 0.

Returns:

A list of names of subfeatures for the Feature sub-class.

Return type:

Tuple[str]

ogd.games.BLOOM.features.CountyFinalPolicySettings module

class ogd.games.BLOOM.features.CountyFinalPolicySettings.CountyFinalPolicySettings(params: GeneratorParameters)[source]

Bases: PerCountyFeature

Subfeatures() List[str][source]

Base function to get a list of names of the sub-feature(s) a given Feature class outputs. By default, a Feature class has no subfeatures. However, if a Feature class is written to output multiple values, it will need to override this function to return an appropriate list. Note, Subfeatures must match the ordering from the override of GetFeatureNames, if returning a list of length > 0.

Returns:

A list of names of subfeatures for the Feature sub-class.

Return type:

Tuple[str]

ogd.games.BLOOM.features.CountyLatestMoney module

class ogd.games.BLOOM.features.CountyLatestMoney.CountyLatestMoney(params: GeneratorParameters)[source]

Bases: PerCountyFeature

Subfeatures() List[str][source]

Base function to get a list of names of the sub-feature(s) a given Feature class outputs. By default, a Feature class has no subfeatures. However, if a Feature class is written to output multiple values, it will need to override this function to return an appropriate list. Note, Subfeatures must match the ordering from the override of GetFeatureNames, if returning a list of length > 0.

Returns:

A list of names of subfeatures for the Feature sub-class.

Return type:

Tuple[str]

ogd.games.BLOOM.features.CountyUnlockCount module

class ogd.games.BLOOM.features.CountyUnlockCount.CountyUnlockCount(params: GeneratorParameters)[source]

Bases: Extractor

static MinVersion() str | None[source]
Base function to get the minimum log version the feature can handle.

A value of None will set no minimum, so all levels are accepted (unless a max is set). Typically default to None, unless there is a required element of the event data that was not added until a certain version. The versions of data accepted by a feature are a responsibility of the Feature’s developer, so this is a required part of interface instead of a config item in the schema.

Returns:

[description]

Return type:

Optional[str]

Subfeatures() List[str][source]

Base function to get a list of names of the sub-feature(s) a given Feature class outputs. By default, a Feature class has no subfeatures. However, if a Feature class is written to output multiple values, it will need to override this function to return an appropriate list. Note, Subfeatures must match the ordering from the override of GetFeatureNames, if returning a list of length > 0.

Returns:

A list of names of subfeatures for the Feature sub-class.

Return type:

Tuple[str]

ogd.games.BLOOM.features.FailCount module

class ogd.games.BLOOM.features.FailCount.FailCount(params: GeneratorParameters)[source]

Bases: Extractor

static MinVersion() str | None[source]
Base function to get the minimum log version the feature can handle.

A value of None will set no minimum, so all levels are accepted (unless a max is set). Typically default to None, unless there is a required element of the event data that was not added until a certain version. The versions of data accepted by a feature are a responsibility of the Feature’s developer, so this is a required part of interface instead of a config item in the schema.

Returns:

[description]

Return type:

Optional[str]

Subfeatures() List[str][source]

Base function to get a list of names of the sub-feature(s) a given Feature class outputs. By default, a Feature class has no subfeatures. However, if a Feature class is written to output multiple values, it will need to override this function to return an appropriate list. Note, Subfeatures must match the ordering from the override of GetFeatureNames, if returning a list of length > 0.

Returns:

A list of names of subfeatures for the Feature sub-class.

Return type:

Tuple[str]

ogd.games.BLOOM.features.GameCompletionStatus module

class ogd.games.BLOOM.features.GameCompletionStatus.GameCompletionStatus(params: GeneratorParameters)[source]

Bases: Extractor

ogd.games.BLOOM.features.NumberOfSessionsPerPlayer module

class ogd.games.BLOOM.features.NumberOfSessionsPerPlayer.NumberOfSessionsPerPlayer(params: GeneratorParameters)[source]

Bases: Extractor

static MinVersion() str | None[source]
Base function to get the minimum log version the feature can handle.

A value of None will set no minimum, so all levels are accepted (unless a max is set). Typically default to None, unless there is a required element of the event data that was not added until a certain version. The versions of data accepted by a feature are a responsibility of the Feature’s developer, so this is a required part of interface instead of a config item in the schema.

Returns:

[description]

Return type:

Optional[str]

ogd.games.BLOOM.features.PerCountyFeature module

class ogd.games.BLOOM.features.PerCountyFeature.PerCountyFeature(params: GeneratorParameters)[source]

Bases: PerCountFeature

COUNTY_LIST = ['Hillside', 'Forest', 'Prairie', 'Wetland', 'Urban'][source]

ogd.games.BLOOM.features.PersistThroughFailure module

class ogd.games.BLOOM.features.PersistThroughFailure.PersistThroughFailure(params: GeneratorParameters)[source]

Bases: Extractor

static MinVersion() str | None[source]
Base function to get the minimum log version the feature can handle.

A value of None will set no minimum, so all levels are accepted (unless a max is set). Typically default to None, unless there is a required element of the event data that was not added until a certain version. The versions of data accepted by a feature are a responsibility of the Feature’s developer, so this is a required part of interface instead of a config item in the schema.

Returns:

[description]

Return type:

Optional[str]

ogd.games.BLOOM.features.SucceededThroughFailure module

class ogd.games.BLOOM.features.SucceededThroughFailure.SucceededThroughFailure(params: GeneratorParameters)[source]

Bases: Extractor

static MinVersion() str | None[source]
Base function to get the minimum log version the feature can handle.

A value of None will set no minimum, so all levels are accepted (unless a max is set). Typically default to None, unless there is a required element of the event data that was not added until a certain version. The versions of data accepted by a feature are a responsibility of the Feature’s developer, so this is a required part of interface instead of a config item in the schema.

Returns:

[description]

Return type:

Optional[str]

Module contents

Initializer for Bloom features