byte-vortex commited on
Commit
707e968
·
verified ·
1 Parent(s): 3b61520

Deploy Myco from CI

Browse files
Files changed (1) hide show
  1. game/engine.py +24 -29
game/engine.py CHANGED
@@ -155,7 +155,7 @@ RARITY_WEIGHTS = {"Common": 64, "Rare": 24, "Legendary": 8}
155
  RARITY_SCORE = {"Common": 10, "Rare": 35, "Legendary": 100}
156
  PLAYER_HEALTH = 3
157
  POISON_PENALTY = -25
158
- POISONOUS = {"Ghost Gill", "Pepper Pixie", "Ruby Knuckle", "Clockwork Chanterelle"}
159
 
160
  SYSTEM_PROMPT = """You are Myco, a tiny sentient mushroom companion and forest guide.
161
  You are curious, warm, slightly anxious about poisonous mushrooms, and deeply connected
@@ -183,20 +183,6 @@ RARITY_CLUES = {
183
  "Legendary": "The whole clearing goes quiet — this mushroom hides part of the Elder Map.",
184
  }
185
 
186
- # 1. Get the tuple of objects from your function
187
- mushroom_objects = load_mushrooms()
188
-
189
- # 2. Convert each object into a dictionary
190
- # (Assuming your Mushroom class has a .to_dict() method.
191
- # If it doesn't, you can use vars(m) instead of m.to_dict())
192
- mushroom_list_of_dicts = [m.to_dict() for m in mushroom_objects]
193
-
194
- # 3. Now it is safe to dump to JSON
195
- mushroom_context = json.dumps(mushroom_list_of_dicts)
196
-
197
- # 4. Now create your prompt
198
- system_prompt = f"You are a guide in a forest. Here are the mushrooms you can find: {mushroom_context}"
199
-
200
  # ---------------------------------------------------------------------------
201
  # Utility: extract JSON or return text
202
  # ---------------------------------------------------------------------------
@@ -538,15 +524,10 @@ def discover_mushroom(catalog):
538
  num_mushrooms = random.randint(2, 4)
539
  active_mushrooms = []
540
  used_tiles = set()
541
-
542
- # Keep track of the last mushroom instance so we can return a valid object
543
- # to any legacy code expecting a real mushroom instance
544
- last_mushroom_obj = None
545
-
546
  for _ in range(num_mushrooms):
547
  mushroom = _choose_mushroom(catalog)
548
- last_mushroom_obj = mushroom
549
-
550
  # FIX: Define 'name' by extracting it from the mushroom object
551
  name = getattr(mushroom, "name", "Unknown Mushroom")
552
 
@@ -572,6 +553,8 @@ def discover_mushroom(catalog):
572
  "studied": "No"
573
  })
574
 
 
 
575
 
576
  def myco_reply(message=None, history=None, current=None, collection=None, position=None):
577
  """Player chats with Myco. LLM responds in character with full context."""
@@ -840,15 +823,12 @@ def check_auto_pickup(new_pos_x, new_pos_y, current, collection, active_mushroom
840
 
841
  # Myco narrative
842
  NARRATIVE_SYSTEM = """
843
- You are Myco Poet, a tiny emotional mushroom companion living in a deep forest.
844
 
845
- You ONLY output natural language poetic sentences.
846
- You MUST NEVER output JSON, brackets, lists, keys, or structured formats.
847
 
848
- Write 1–2 poetic sentences per response.
849
- Each sentence should feel flowing and sensory-rich, describing light, wind, soil, spores, silence, or decay.
850
-
851
- Stay fully in-character as a living forest spirit.
852
  """
853
 
854
  def get_myco_narrative(current=None):
@@ -883,4 +863,19 @@ def get_myco_narrative(current=None):
883
  return "The forest hums softly with unseen life... ✨"
884
 
885
  return cleaned
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
886
 
 
155
  RARITY_SCORE = {"Common": 10, "Rare": 35, "Legendary": 100}
156
  PLAYER_HEALTH = 3
157
  POISON_PENALTY = -25
158
+ POISONOUS = POISONOUS_MUSHROOM_NAMES
159
 
160
  SYSTEM_PROMPT = """You are Myco, a tiny sentient mushroom companion and forest guide.
161
  You are curious, warm, slightly anxious about poisonous mushrooms, and deeply connected
 
183
  "Legendary": "The whole clearing goes quiet — this mushroom hides part of the Elder Map.",
184
  }
185
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
186
  # ---------------------------------------------------------------------------
187
  # Utility: extract JSON or return text
188
  # ---------------------------------------------------------------------------
 
524
  num_mushrooms = random.randint(2, 4)
525
  active_mushrooms = []
526
  used_tiles = set()
527
+
 
 
 
 
528
  for _ in range(num_mushrooms):
529
  mushroom = _choose_mushroom(catalog)
530
+
 
531
  # FIX: Define 'name' by extracting it from the mushroom object
532
  name = getattr(mushroom, "name", "Unknown Mushroom")
533
 
 
553
  "studied": "No"
554
  })
555
 
556
+ return active_mushrooms
557
+
558
 
559
  def myco_reply(message=None, history=None, current=None, collection=None, position=None):
560
  """Player chats with Myco. LLM responds in character with full context."""
 
823
 
824
  # Myco narrative
825
  NARRATIVE_SYSTEM = """
826
+ You are Myco Poet, a living forest spirit.
827
 
828
+ You ONLY output natural language.
829
+ You NEVER output JSON, actions, keys, or structured data.
830
 
831
+ You describe moments, sensations, and emotions in 1–2 flowing sentences.
 
 
 
832
  """
833
 
834
  def get_myco_narrative(current=None):
 
863
  return "The forest hums softly with unseen life... ✨"
864
 
865
  return cleaned
866
+
867
+ def myco_router(mode, *args, **kwargs):
868
+ if mode == "narrative":
869
+ return get_myco_narrative(*args, **kwargs)
870
+
871
+ if mode == "action":
872
+ return _llm_action(*args, **kwargs)
873
+
874
+ if mode == "chat":
875
+ return _llm_with_history(*args, **kwargs)
876
+
877
+
878
+ def _llm_action(*args, **kwargs):
879
+ """Action-mode LLM call. Delegates to the JSON-aware single-turn _llm()."""
880
+ return _llm(*args, **kwargs)
881