Skip to content

Commit 8d98bbd

Browse files
committed
this is a temp commit
1 parent bf2b4fb commit 8d98bbd

File tree

2 files changed

+23
-12
lines changed

2 files changed

+23
-12
lines changed

textworld/challenges/spaceship/spaceship_game.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,8 @@ def make_game(settings: Mapping[str, str], options: Optional[GameOptions] = None
332332
gm.set_player(starting_room)
333333

334334
else:
335-
# gm.set_player(us_lab)
336-
gm.set_player(sleep_station)
335+
gm.set_player(us_lab)
336+
# gm.set_player(sleep_station)
337337

338338
key_7 = gm.new(type='k', name="hearty key")
339339
key_7.infos.desc = "This key is shaped like a heart, not a normal key for a spaceship, ha ha ha..."
@@ -356,10 +356,10 @@ def make_game(settings: Mapping[str, str], options: Optional[GameOptions] = None
356356
from maker import test_commands
357357
test_commands(gm, [
358358
# 'look',
359-
# 'open door A',
360-
# 'go north',
361-
'check laptop for email',
362-
# 'go south'
359+
'open door A',
360+
'go north',
361+
# 'check laptop for email',
362+
'go south'
363363
])
364364

365365
return game
@@ -374,10 +374,16 @@ def quest_design_medium(game):
374374

375375
# 1. Is the Player in the Sleeping Station
376376
win_quest = Event(conditions={
377-
game.new_fact("at", game._entities['P'], game._entities['r_0']),
378-
game.new_fact("read/e", game._entities['cpu_0']),
377+
game.new_fact("at", game._entities['P'], game._entities['r_0'])
379378
})
380-
quests.append(Quest(win_events=[], fail_events=[win_quest]))
379+
quests.append(Quest(win_events=[win_quest], fail_events=[], reward=0))
380+
381+
fail_quest = Event(conditions={
382+
game.new_fact("event", game._entities['P'], game._entities['r_0']),
383+
game.new_fact("at", game._entities['P'], game._entities['r_1']),
384+
game.new_fact("open", game._entities['d_0']),
385+
})
386+
quests.append(Quest(win_events=[], fail_events=[fail_quest]))
381387

382388
game.quests = quests
383389

textworld/generator/inform7/world2inform7.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ def gen_source(self, seed: int = 1234) -> str:
300300

301301
objective = self.game.objective.replace("\n", "[line break]")
302302
maximum_score = 0
303+
wining = 0
303304
for quest_id, quest in enumerate(self.game.quests):
304305
maximum_score += quest.reward
305306

@@ -339,6 +340,7 @@ def gen_source(self, seed: int = 1234) -> str:
339340
quest_ending_conditions += win_template.format(conditions=conditions,
340341
reward=quest.reward,
341342
quest_id=quest_id)
343+
wining += 1
342344

343345
quest_ending = """\
344346
Every turn:\n{conditions}
@@ -347,13 +349,16 @@ def gen_source(self, seed: int = 1234) -> str:
347349
source += textwrap.dedent(quest_ending)
348350

349351
# Enable scoring is at least one quest has nonzero reward.
350-
if maximum_score != 0:
352+
if maximum_score >= 0:
351353
source += "Use scoring. The maximum score is {}.\n".format(maximum_score)
352354

355+
print(maximum_score)
356+
print(wining)
353357
# Build test condition for winning the game.
354358
game_winning_test = "1 is 0 [always false]"
355-
if len(self.game.quests) > 0:
356-
game_winning_test = "score is maximum score"
359+
if wining > 0:
360+
if maximum_score != 0:
361+
game_winning_test = "score is maximum score"
357362

358363
# Remove square bracket when printing score increases. Square brackets are conflicting with
359364
# Inform7's events parser in git_glulx_ml.py.

0 commit comments

Comments
 (0)