Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Simplify RuleEngine API #151

Open
wants to merge 2 commits into
base: mf3-dev
Choose a base branch
from
Open

Conversation

dejabot
Copy link
Contributor

@dejabot dejabot commented Jan 10, 2025

Description

Remove Rule.Builder. Callers still call RuleEngine.addRule(), with simplified syntax. Allow Rules to be modified, eg to specify a finishedTriggering action - but once RuleEngine.run() is called, "seal" the RuleEngine's Rules so they cannot be modified further.

How Has This Been Tested?

  • Unit tests: [Add your description here]
  • Simulator testing: [Add your description here]
  • On-robot bench testing: [Add your description here]
  • On-robot field testing: [Add your description here]

…urn a Rule that can be modified further, eg with a finishedTriggeringProcedure.
this prevents accidental modification of rules after the containing ruleengine starts getting used.

also switch to a LinkedHashMap for storing rules and tweak some of the methods used in unit tests.
@dejabot dejabot requested a review from rcahoon January 10, 2025 03:09
@rcahoon
Copy link
Member

rcahoon commented Jan 10, 2025

Do you want to open this in 2025 instead?

@@ -24,8 +24,8 @@
* public class MyRules extends RuleEngine {
* public MyRules() {
* // add rule to spin up the shooter when the boxop presses the right trigger on the gamepad
* rules.add(Rule.create("spin up shooter", gamepad.getButton(InputConstants.XBOX_RT)).
* withNewlyTriggeringProcedure(() -> new ShooterSpin(shooter)));
* rules.add("spin up shooter", gamepad.getButton(InputConstants.XBOX_RT),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/rules.add/addRule/

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants