Skip to content

Commit

Permalink
Merge pull request #18 from ShiJbey/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
ShiJbey authored May 20, 2023
2 parents f397122 + 34ace9b commit 133d5f4
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 19 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres mostly to [Semantic Versioning](https://semver.org/spec
There may be minor-version updates that contain breaking changes, but do not warrant
incrementing to a completely new version number.

## [0.11.1]

### Fixes

- The Tracery class is now seeded inside the Neighborly constructor

## [0.11.0]

**This update has breaking changes from version 0.10.x**
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
src="https://user-images.githubusercontent.com/11076525/165836171-9ffdea6e-1633-440c-be06-b46e1e3e4e04.png"
>
<br>
Neighborly (v0.10.0)
Neighborly
</h1>

<p align="center">
Expand Down
2 changes: 1 addition & 1 deletion src/neighborly/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION = "0.11.0"
VERSION = "0.11.1"
9 changes: 6 additions & 3 deletions src/neighborly/components/business.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,9 +341,12 @@ def get_open_positions(self) -> List[str]:
List[str]
All the names of all open positions at the business.
"""
return sum(
[[title] * count for title, count in self._open_positions.items()], []
)
open_positions: List[str] = []

for title, count in self._open_positions.items():
open_positions.extend([title] * count)

return open_positions

def get_employees(self) -> List[int]:
"""Get all current employees.
Expand Down
2 changes: 1 addition & 1 deletion src/neighborly/core/roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def get(self, role_name: str) -> Optional[GameObject]:
def __len__(self) -> int:
return len(self._roles)

def __bool__(self) -> int:
def __bool__(self) -> bool:
return bool(self._roles)

def __getitem__(self, role_name: str) -> GameObject:
Expand Down
11 changes: 11 additions & 0 deletions src/neighborly/core/tracery.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@ class Tracery:
_grammar: tracery.Grammar = tracery.Grammar({})
"""The grammar instance."""

@classmethod
def set_rng_seed(cls, seed: Union[int, str]) -> None:
"""Set the seed for RNG used during rule evaluation.
Parameters
----------
seed
An arbitrary seed value
"""
cls._grammar.rng.seed(seed)

@classmethod
def add_rules(cls, rules: Dict[str, Union[str, List[str]]]) -> None:
"""Add grammar rules.
Expand Down
12 changes: 3 additions & 9 deletions src/neighborly/plugins/defaults/create_town.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,13 @@ def load_spawn_table(cls, table_type: str, file_path: _AnyPath):
The file path to the file to load data from.
"""
with open(file_path, "r") as csv_file:
df = pandas.read_csv(csv_file)
df = pandas.read_csv(csv_file) # type: ignore

if table_type not in cls.prefab_data:
cls.prefab_data[table_type] = []

for _, row in df.iterrows():
cls.prefab_data[table_type].append(row.to_dict())

pass
# next(reader, None) # skip the headers

# for row in reader:
# cls.prefab_data[table_type].append(row)
for _, row in df.iterrows(): # type: ignore
cls.prefab_data[table_type].append(row.to_dict()) # type: ignore

def process(self, *args: Any, **kwargs: Any) -> None:
settlement = spawn_settlement(self.world, self.settlement_prefab)
Expand Down
5 changes: 1 addition & 4 deletions src/neighborly/plugins/talktown/spawn_tables.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import pathlib
from typing import Any, Dict, List
from typing import Any

import yaml

from neighborly.core.ecs import GameObjectFactory
from neighborly.simulation import Neighborly, PluginInfo
from neighborly.plugins.defaults.create_town import CreateDefaultSettlementSystem

Expand Down
2 changes: 2 additions & 0 deletions src/neighborly/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import neighborly.components as components
import neighborly.core.relationship as relationship
from neighborly.core.tracery import Tracery
import neighborly.factories as factories
import neighborly.systems as systems
from neighborly.__version__ import VERSION
Expand Down Expand Up @@ -94,6 +95,7 @@ def __init__(self, config: Optional[NeighborlyConfig] = None) -> None:

# Seed RNG for libraries we don't control, like Tracery
random.seed(self.config.seed)
Tracery.set_rng_seed(self.config.seed)

# Set the relationship schema
GameObjectFactory.add(
Expand Down

0 comments on commit 133d5f4

Please sign in to comment.