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

WIP: autojustice #594

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

WIP: autojustice #594

wants to merge 19 commits into from

Conversation

Igualop
Copy link

@Igualop Igualop commented Feb 4, 2023

autojustice

This is a script that automate most of the tedious parts of the justice system.

Features

  • Auto interview visitors.
  • Auto interview accused units.
  • Auto convict non-citizens confessed crimes.

Notes

  • There are a couple of things listed as TODO, but the core functions seems to be working fine.

  • This script was (afk) tested on a running fort for a dozen hours without issues, but since I'm totally new with df/dfhack/lua I can't guarantee that all the modifications made to the crime data are 100% correct.

  • "justicetools.lua" file contains helper methods used by the "autojustice.lua". Not sure if I should merge those two scripts or where to even put the "justicetools.lua".

  • I'm not sure I've correctly followed all naming conventions, feel free to comment on that.

  • There are a couple of options that can be added in case everything is working fine (i.e: auto convict citizens when the punishment is just jail time, add notifications to convictions and confessions).

  • Might need to test on worlds with multiple forts as crime reports seems to have a siteId field mapped on them.

Known Issues

  • I had a goblin poet getting convicted even though he did join my fortress. I'm not sure why he is not being considered as a citizen.

Copy link
Member

@myk002 myk002 left a comment

Choose a reason for hiding this comment

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

I'll have to find someone more knowledgeable about the justice system to review the business logic, but overall it looks pretty good!

autojustice.lua Outdated Show resolved Hide resolved
autojustice.lua Outdated Show resolved Hide resolved
@@ -0,0 +1,176 @@
--@ module = true

Copy link
Member

Choose a reason for hiding this comment

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

if you want to keep this separate, this file should be moved to internal/autojustice/justicetools.lua so it doesn't show up as a runnable script. However, together they are about 500 lines, which is about average for a script like this. It might be simpler if you just combine the two.

Copy link
Author

Choose a reason for hiding this comment

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

I also think that it's simpler to combine the two. My only reasoning to keep these files separate is just to facilitate in case others might want get/change some info from the justice system.

autojustice.lua Outdated Show resolved Hide resolved
autojustice.lua Show resolved Hide resolved
autojustice.lua Outdated Show resolved Hide resolved
Copy link
Member

@myk002 myk002 left a comment

Choose a reason for hiding this comment

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

note that gui/control-panel was just added. Until I can get a proper query interface that allows a tool to report when it can be enabled, could you add "autojustice" to the FORT_SERVICES table in gui/control-panel?

autojustice.lua Outdated Show resolved Hide resolved
Options
-------

``-j``, ``--jailcitizen``
Copy link
Member

Choose a reason for hiding this comment

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

in the code, you have these options taking an argument, but I don't see it documented here. This should be:

``-j``, ``--jailcitizen true|false``

now that you have configuration options, you should also write a simple GUI to configure them, which should also show statistics and other useful information. See gui/autofish for an example. That can come in a different PR, though, if you like

Copy link
Author

Choose a reason for hiding this comment

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

I will take a look on the GUI part later on.

Should I still add the "autojustice" entry to the gui/controrl-panel even without a GUI?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, the control panel will automatically pick up the GUI config when it's added. Until then, autojustice will just not have a button for launching the gui

docs/autojustice.rst Outdated Show resolved Hide resolved
@myk002
Copy link
Member

myk002 commented Feb 7, 2023

  • I had a goblin poet getting convicted even though he did join my fortress. I'm not sure why he is not being considered as a citizen.

btw, this is because permanent residents are not "citizens". you might have to make a special check for this case

@myk002
Copy link
Member

myk002 commented Feb 7, 2023

be sure to merge justicetools.lua into the main file (or move it into internal) to solve the docs build error

- Added region comments
@myk002
Copy link
Member

myk002 commented Feb 14, 2023

Looks good! If this is ready for merge, could you fix the pre-commit.ci errors and remove WIP from the PR title?

@drhead
Copy link

drhead commented Feb 17, 2023

I would appreciate an option to not have the script handle automatic interrogations for visitors. I do find that some visitors who turn out to be innocent want to leave after an interrogation, so I don't think it's necessarily a good idea to interrogate absolutely everyone.

Following up implicated suspects is fine, that should be separated from this ideally.

@drhead
Copy link

drhead commented Feb 18, 2023

Testing the script out, I also noticed that goblins during sieges are queued for interrogation as if they were visitors.

@myk002
Copy link
Member

myk002 commented Feb 23, 2023

@Igualop could you address the issues drhead found before merge?

@myk002
Copy link
Member

myk002 commented Mar 23, 2023

Has there been any progress on this PR?

@master-spike
Copy link
Contributor

I've been looking at this as I actually started working on a plugin with similar features that does the same thing, before it had been pointed out that this PR existed. @Igualop if you're still around and can remember stuff about this, I do have a question - for those unk_vector_...s that you noticed always had 1 element in them, I've not noticed them contain anything at all at any point. I've also noticed that when setting the convicted ids the fortress and victim doesn't get the relevant happy/sad thoughts, like they would hitting the convict button. Is it possible that those vectors are related to this?

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.

4 participants