Skip to content

Commit

Permalink
Merge pull request #19 from ShiJbey/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
ShiJbey authored May 22, 2023
2 parents 133d5f4 + 76c2e16 commit 9a7aa66
Show file tree
Hide file tree
Showing 15 changed files with 217 additions and 139 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ 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.2]

- Fixed problem with non-determinism caused by VirtuesFactory iterating sets

## [0.11.1]

### Fixes
Expand Down
72 changes: 21 additions & 51 deletions samples/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,71 +13,41 @@
"""

from neighborly import NeighborlyConfig
from neighborly.data_collection import DataCollector
from neighborly.server import NeighborlyServer
from neighborly.utils.common import (
add_character_to_settlement,
spawn_character,
spawn_settlement,
)

app = NeighborlyServer(
NeighborlyConfig.parse_obj(
{
"seed": "Apples",
"time_increment": "1mo",
"relationship_schema": {
"Friendship": {
"min_value": -100,
"max_value": 100,
},
"Romance": {
"min_value": -100,
"max_value": 100,
},
"InteractionScore": {
"min_value": -5,
"max_value": 5,
},
"components": {
"Friendship": {
"min_value": -100,
"max_value": 100,
},
"Romance": {
"min_value": -100,
"max_value": 100,
},
"InteractionScore": {
"min_value": -5,
"max_value": 5,
},
}
},
"plugins": [
"neighborly.plugins.defaults.names",
"neighborly.plugins.defaults.characters",
"neighborly.plugins.defaults.businesses",
"neighborly.plugins.defaults.residences",
"neighborly.plugins.defaults.life_events",
"neighborly.plugins.defaults.ai",
],
"settings": {"new_families_per_year": 10},
"neighborly.plugins.defaults.all",
"neighborly.plugins.talktown.spawn_tables",
"neighborly.plugins.talktown",
]
}
)
)


def main():
west_world = spawn_settlement(app.sim.world, "West World")

delores = spawn_character(
app.sim.world,
"character::default::female",
first_name="Delores",
last_name="Abernathy",
age=32,
)

add_character_to_settlement(delores, west_world)

app.sim.world.get_resource(DataCollector).create_new_table(
"default", ("pizza", "apples")
)
app.sim.world.get_resource(DataCollector).add_table_row(
"default", {"pizza": 2, "apples": 4}
)
app.sim.world.get_resource(DataCollector).add_table_row(
"default", {"pizza": 87, "apples": 1}
)
app.sim.world.get_resource(DataCollector).add_table_row(
"default", {"pizza": 27, "apples": 53}
)

app.sim.run_for(1)
app.run()


Expand Down
4 changes: 3 additions & 1 deletion samples/talktown.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
sim = Neighborly(
NeighborlyConfig.parse_obj(
{
"seed": "Apples",
"time_increment": "1mo",
"relationship_schema": {
"components": {
Expand All @@ -39,7 +40,7 @@
"neighborly.plugins.defaults.all",
"neighborly.plugins.talktown.spawn_tables",
"neighborly.plugins.talktown",
],
]
}
)
)
Expand All @@ -49,6 +50,7 @@
sim.run_for(140)
elapsed_time = time.time() - st


print(f"World Date: {sim.date.to_iso_str()}")
print("Execution time: ", elapsed_time, "seconds")

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.1"
VERSION = "0.11.2"
7 changes: 1 addition & 6 deletions src/neighborly/components/business.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,12 +341,7 @@ def get_open_positions(self) -> List[str]:
List[str]
All the names of all open positions at the business.
"""
open_positions: List[str] = []

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

return open_positions
return [title for title, count in self._open_positions.items() if count > 0]

def get_employees(self) -> List[int]:
"""Get all current employees.
Expand Down
6 changes: 3 additions & 3 deletions src/neighborly/components/shared.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

from dataclasses import dataclass
from typing import Any, Dict, Iterable, Iterator, Optional, Set
from typing import Any, Dict, Iterable, Iterator, Optional

from ordered_set import OrderedSet # type: ignore

Expand Down Expand Up @@ -218,7 +218,7 @@ class FrequentedLocations(Component, ISerializable):

__slots__ = "locations"

locations: Set[int]
locations: OrderedSet[int]
"""A set of GameObject IDs of locations."""

def __init__(self, locations: Optional[Iterable[int]] = None) -> None:
Expand All @@ -229,7 +229,7 @@ def __init__(self, locations: Optional[Iterable[int]] = None) -> None:
An iterable of GameObject IDs of locations.
"""
super().__init__()
self.locations = set(locations) if locations else set()
self.locations = OrderedSet(locations) if locations else OrderedSet()

def add(self, location: int) -> None:
"""Add a new location.
Expand Down
Loading

0 comments on commit 9a7aa66

Please sign in to comment.