-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add tests for item possession in goal criteria #859
Conversation
condition: |- | ||
as base { | ||
itemCount <- count "tree"; | ||
return $ itemCount > 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not succeed even after grab
-bing the tree
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been poking at this a bit. Curiously, I've found that it does work correctly if the test is wrapped in a try
block, like this:
as base {
try {
itemCount <- count "tree";
return $ itemCount > 0
} { return false };
};
In theory this should not make a difference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The runtime code for has
and count
is almost identical. The one big difference between them which seems like it might be relevant is that has
does not require any capabilities to use, whereas count
requires a counter
. But in theory the condition checking robot should be able to use count
whether base
has a counter
or not (and indeed, if I add a counter
installed on base
it does not change anything).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, maybe base can not count or something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really want to figure out what exceptions are being thrown but I'm not sure how to export that information. @xsebek, any ideas?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@byorgey I just checked by printing exceptions from the hypothetical check and there are none.
I just added this:
sendIO $ putStr "ERROR: "
sendIO $ print m
here:
Lines 137 to 146 in e73a284
-- Log exceptions in the message queue so we can check for them in tests | |
Left exn -> do | |
em <- use entityMap | |
time <- use ticks | |
let h = hypotheticalRobot (Out VUnit emptyStore []) 0 | |
hid = view robotID h | |
hn = view robotName h | |
farAway = V2 maxBound maxBound | |
let m = LogEntry time ErrorTrace hn hid farAway $ formatExn em exn | |
emitMessage m |
Weirdly this is also a transformation that fixes the condition:
t <- time;
if (t < 0) {return true} {
as base {
itemCount <- count "tree";
return $ itemCount > 0;
};
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at debug logs (see the debug branch), the count is correct:
f6aeba3
to
f6cb2e9
Compare
f6cb2e9
to
70c17f9
Compare
Towards #858