Comments (4)
Hi Marc, thank you and sorry for the delay in responding. These examples and the twl file are perfect in explaining how to add actions/rules to the game. Thank you so much! Let me have a play with these and ask you further if I struggle with the new logic :).
from textworld.
Hi, correct me if I'm wrong but I believe you want something like this right?
apple = M.new(type='f', name='apple')
apple_eaten_event = Event(conditions={M.new_fact("eaten", apple)})
q1 = Quest(win_events=[apple_eaten_event]
If you really wish to define a quest according to an action, you can do the following:
room = M.new("kitchen")
apple = M.new(type='f', name='apple')
room.add(apple)
q1 = M.new_quest_using_commands(["take apple", "eat apple"])
or
apple_eaten_event = M.new_event_using_commands(["take apple", "eat apple"])
q1 = Quest(win_events=[apple_eaten_event]
Let me know if that's not it. Happy to discuss it more.
from textworld.
Perfect, thank you yes that's what I want to do. When would you use the object Action and can it be used for new action?
from textworld.
Great!
Regarding your follow-up question, under the hood, the Event
class will look at the last actions
and use its postconditions
as the conditions
. So, your original code is totally fine to create Event
and Quest
objects.
However, when building the game, TextWorld tries to infer the text commands from the event's actions. In your case, the eat
action does not match any rule found in TextWorld's KnowledgeBase.
from textworld.generator import GameMaker, Event, Quest
from textworld.logic import Action
M = GameMaker()
apple = M.new(type='f', name='apple')
eat = Action(name='eat', preconditions=[], postconditions=[M.new_fact("eaten", apple)])
print(eat)
print(M.options.kb.logic.rules['eat'])
eat :: -> eaten(f_0: f) # print(eat)
eat :: in(f, I) -> eaten(f) # print(M.options.kb.logic.rules['eat'])
As you can see, your new action is missing the precondition facts to match the existing eat
rule from the KnowledgeBase
.
For a completely new action (i.e., that is not already in the KB), you would need to add its Rule
(i.e., the general form of an action) first. To do so, you will have to add a new .twl
logic file containing the new rule, any new predicates, and the matching Inform7 code. As an example, you can check the tw_cooking games, in particular meal.twl.
Since extending TextWorld is far from being user-friendly at the moment, I'm happy to help you out creating new logic if that's something you need.
from textworld.
Related Issues (20)
- Accessing oracle policy commands for tw-cooking games HOT 5
- make_batch2 in textworld.gym HOT 1
- update grammar file to reflect the logic HOT 4
- Optional and repeatable quest HOT 6
- Can Textworld support multiple players? HOT 2
- Can we generate full description at each step? HOT 4
- Using Action-based to create repeatable reward only when the action is executed HOT 1
- Translation Request HOT 1
- This repo is missing important files
- why doesn't work on the colab either else enviroment based on cloud? HOT 4
- Fail to install on M1/M2 Macos (arm64) HOT 8
- Unable to import textworld in colab HOT 4
- *** buffer overflow detected ***: terminated HOT 3
- [Gym] - Depreciation Warning ("rewrite env with new step API") HOT 1
- [Numpy] - Depreciation Warning (np.bool8 is deprecated in numpy 1.24) HOT 2
- [Gym] - UserWarning (obs returned by the `step()` method is not within the observation space) HOT 2
- [Frotz / GitGlulx / Gym / (Jeriocho) ] - Question, Bug, Feature Request? HOT 3
- unable to install on MacOS 14.4 HOT 3
- install textworld problems HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from textworld.