Skip to content

Fix sim edge cases and optimize machine processing#4

Open
oFOXo wants to merge 1 commit intomainfrom
codex/create-solarpunk-survival-game-with-python-c0d7ob
Open

Fix sim edge cases and optimize machine processing#4
oFOXo wants to merge 1 commit intomainfrom
codex/create-solarpunk-survival-game-with-python-c0d7ob

Conversation

@oFOXo
Copy link
Copy Markdown
Owner

@oFOXo oFOXo commented May 2, 2026

No description provided.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6cfade4867

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scifarm/sim.py
Comment on lines +146 to +150
self.day = int(data["day"])
self.player = list(data["player"])
self.resources = ResourceState(**data["resources"])
self.machines = [Machine(**m) for m in data["machines"]]
self.genome.features = [FeatureGene(**f) for f in data["features"]]
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Validate loaded save payload before assigning state

load_game() only handles JSON syntax errors, but it immediately dereferences required keys and constructors (data["day"], ResourceState(**...), etc.) without schema checks. A syntactically valid but malformed save file (missing keys, wrong types, wrong shapes) will raise KeyError/TypeError and crash instead of returning False, which makes the in-game load hotkey fragile for real-world corrupted or migrated saves.

Useful? React with 👍 / 👎.

Comment thread scifarm/sim.py
Comment on lines +170 to +173
elif action == "build_solar" and r.materials >= 8:
r.materials -= 8
self.world[y][x] = "solar"
self.machines.append(Machine("solar", x, y, "energy", 3, 0))
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Prevent stacking multiple machines on one tile

The build branches allow placing a machine regardless of the current tile contents, and each call appends another Machine entry even if one already exists at the same coordinates. This permits repeated builds on the same cell, creating invisible duplicate producers/consumers (world shows one tile, machines contains many), which skews resource generation and breaks simulation consistency.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant