Skip to content
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

New Feature: autotraining #1411

Open
wants to merge 44 commits into
base: master
Choose a base branch
from

Conversation

realSquidCoder
Copy link
Contributor

Code for dwarves to hit the gym when they yearn for the gains. Assigns dwarves to a military squad until they have fulfilled their need for Martial Training

Code for dwarves to hit the gym when they yearn for the gains.
Assigns Dwarves to a military squad until they have fulfilled their need for Martial Training
@realSquidCoder realSquidCoder marked this pull request as draft March 2, 2025 04:22
@realSquidCoder realSquidCoder marked this pull request as ready for review March 2, 2025 18:50
@chdoc
Copy link
Member

chdoc commented Mar 6, 2025

Here are some observations:

  1. I'm not particularly fond of the name gym, because it makes me think of using screw pumps to increase strength. Maybe just call it martial-training or martial-arts-class
  2. I think the squad should just be chosen from a list, instead of requiring the user to name a squad in a particular way. I think that squads are intended to use DF names, and I would not be surprised if the ability to just input strings would disappear. Maybe, if there is only a single squad that does not have a uniform set, default to that.
  3. I would like an option to not automatically replace the squad leader. This way you could actually put a decently skilled teacher in charge of the squad. Also, squad leaders are nobles and this would avoid at least some of the historical figure noise.

@chdoc
Copy link
Member

chdoc commented Mar 6, 2025

  1. It would be nice to have an option to automatically exclude holders of relevant positions (e.g. the manager ...)

@realSquidCoder
Copy link
Contributor Author

1. I'm not particularly fond of the name `gym`, because it makes me think of using screw pumps to increase strength. Maybe just call it `martial-training` or `martial-arts-class`

Ok thats not a terrible idea. the original name was just needs-training so maybe martial-training works

2. I think the squad should just be chosen from a list, instead of requiring the user to name a squad in a particular way. I think that squads are intended to use DF names, and I would not be surprised if the ability to just input strings would disappear. Maybe, if there is only a single squad that does not have a uniform set, default to that.

the reason you need to make a squad (tho i want to make the script make it's own squad in a later stage) is because it lets you give them the proper schedule and teacher leader.

3. I would like an option to not automatically replace the squad leader. This way you could actually put a decently skilled teacher in charge of the squad. Also, squad leaders are nobles and this would avoid at least some of the historical figure noise.

its not supposed to replace the leader, have you seen it doing that?

@realSquidCoder
Copy link
Contributor Author

  1. It would be nice to have an option to automatically exclude holders of relevant positions (e.g. the manager ...)

you can set up ppl to be ignored but auto ignoring ppl is not a bad idea either. who all should be ignored you think?

@realSquidCoder
Copy link
Contributor Author

actually, because i intend this to join the automation tab, perhaps autotraining would be a better name

- Clean up documentation
- Add option to change squad name.
- persist the enabled state, the threshold, and the squad name.
- fixed findNeed function
- renamed script to `autotraining`
- made the ignore flag more clear and more changable
- fixed 1 sided military link in `addTraining`
Also tell the user when data was persisted (mostly for debugging)
and update the docs to account.
@realSquidCoder realSquidCoder changed the title New Feature: gym New Feature: autotraining Mar 12, 2025
Copy link
Member

@chdoc chdoc left a comment

Choose a reason for hiding this comment

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

Making another pass to see what would be needed for a GUI tool

@chdoc
Copy link
Member

chdoc commented Mar 15, 2025

So here is what I think would be needed for the UI tool:

  1. extend the state with tables containing the ids of training squads and ignored units. The most convenient to work with is to map unit ids to booleans: state.ignored[unit.id] = true. This can be iterated over with pairs and used as a test without iteration. However, this requires some care when persisting. See how this is done in idle-crafting. It is important to store IDs and not pointers, because both units and squads can disappear between runs.
  2. Add a function persist_state, because persisting the state is now nontrivial
  3. provide public functions for accessing and modifying this new state (calling persist_state after modifications)
  4. (optional) extend the command-line interface to the new configuration options
  5. Make the tool iterate only over configured squads and make it skip over ignored units, adopting the configuration if a configured squad disappears between runs.

Coming to think of it, I'm not entirely certain whether it is more convenient to store unit.id or unit.hist_figure_id for ignored units. I would leave that decision up to you.

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

Successfully merging this pull request may close these issues.

2 participants