eykd / owyl

A python behavior tree for implementing fast and flexible AI.
BSD 3-Clause "New" or "Revised" License
69 stars 16 forks source link

Found incorrect behavior (I think). Wrote some tests. #2

Open Gaboose opened 9 years ago

Gaboose commented 9 years ago

I'm kind of new to behavior trees so it'd be nice if someone confirmed whether these failures are real / tests are correct. Though I'm fairly certain repeatUntilSucceed and repeatUntilFail should execute its child more than once to operate correctly.

Here's how the tests fail:

FAIL: testParallel_DelayedFailure (__main__.OwylTests)
Can parallel fail if child fails later (all succeed)?
AssertionError: Lists differ: [True] != [False]

FAIL: testParallel_DelayedSuccess (__main__.OwylTests)
Can parallel succeed if child succeeds later (one succeeds)?
AssertionError: Lists differ: [False] != [True]

FAIL: testRepeatAlways_Count (__main__.OwylTests)
Does repeatAlways execute its child with every tick?
AssertionError: 50 != 100

FAIL: testRepeatUntilFail_Count (__main__.OwylTests)
Does repeatUntilFail execute its child with every tick?
AssertionError: 1 != 100

FAIL: testRepeatUntilSucceed_Count (__main__.OwylTests)
Does repeatUntilSucceed execute its child with every tick?
AssertionError: 1 != 100
linas commented 9 years ago

Did you mean "more than once" or "more than zero?" Normally, if one is asked to do something until one suceeds, and one gets it on the very first try, you get a gold star, and don't have to do it again.

If precision is a requirement, then the semantics are usually "at least once, and at most once". For example: an automated banking machine: "(repeat-until-success: call bank; decrement account balance $50); then dispense cash-money $50" -- You don't want to decrement $50 twice: you want to keep trying till you contact the bank, but once you succeeed, you are done.

Gaboose commented 9 years ago

I get that. But here, following your example, the success-check "try call bank" gets executed only once even though the network is down (the test is rigged so the repeatUntilSucceed never succeeds) and I stepped through the tree 100 times.

eykd commented 9 years ago

Yes, there's something wrong with parallel. Good find! I'm looking into it.

linas commented 9 years ago

Any reason this pull request cannot be merged?

Since Gaboose and I plan to use behvaior trees more and more, would it be possible to be listed as a project participant/maintainer for this project?

Gaboose commented 9 years ago

@eykd I took the liberty of fixing these myself 5d73706e1ead700a4e7d52345ebc355613a339a6 . All tests succeed.

eykd commented 9 years ago

Hey guys, sorry for the radio silence. I took a couple weeks off around Christmas and the New Year, and now I'm catching up on everything. In investigating this issue I discovered #3 which is potentially a serious issue as well. I was working on a fix before the break. I'll try to have that packaged up this week, potentially incorporating your changes @Gaboose once I've reviewed them. Thanks.

Gaboose commented 9 years ago

Thanks for looking into this. I myself can't tell whether visit's leaky values are an issue or not.