Ticket #156 (new task)
Owl code refactorization
| Reported by: | gunnar | Owned by: | gnugo |
|---|---|---|---|
| Priority: | normal | Milestone: | Future |
| Component: | source | Version: | |
| Severity: | normal | Keywords: | |
| Cc: | patch: | yes |
Description
The aim of this ticket is to address two structural weaknesses of the owl code. The first one is that there is a considerable amount of code duplication in owl_attack(), owl_defend(), do_owl_attack(), do_owl_defend(), owl_threaten_attack(), owl_threaten_defense(), owl_does_attack(), owl_does_defend(), owl_connection_defends(), owl_confirm_safety(), and owl_substantial(). The second weakness is that in some of those functions the owl data is initialized from dragon and worm data when stackp>0, which is shaky to say the least.
Practically enough these weaknesses can be addressed simultaneously. The idea is that the parts of do_owl_attack() and do_owl_defend() involving playing a move and updating the owl information are split off to two new functions owl_attack_trymove() and owl_defend_trymove(). Then all the rest of the functions listed above (except possibly owl_substantial()) do owl initialization at stackp=0 and then use the owl_*_trymove() functions to play the move they need before calling either of do_owl_attack() and do_owl_defend().
Attachments
Regression Results
| Attachment | Rev. | PASS | FAIL | Nodes | Status | |
| gunnar_7_11.4.diff | 2381 | crashed in regressions | details |

