HentHighSchool Development Forum

Game Development => HHS+ => Topic started by: tiquionophist on May 31, 2022, 06:19 AM

Title: [Tool] Tiquionophist's Class Scheduler [1.6.0]
Post by: tiquionophist on May 31, 2022, 06:19 AM
I've created a standalone application which generates class schedules based on teacher assignments and the number of times each subject should be taught per week. This makes it easy to specify the way you want your school to be run and let this program figure out how to satisfy those requirements.

Latest release: 1.6.0 (https://github.com/tiquionophist/hhs-scheduler/releases/tag/v1.6.0), supporting HHS+ 1.10.5

Features:

The source code can be found on GitHub (https://github.com/tiquionophist/hhs-scheduler); see the README for instructions on installation (https://github.com/tiquionophist/hhs-scheduler#installation) and usage (https://github.com/tiquionophist/hhs-scheduler#usage). Please report issues, make feature requests, etc. there or in this thread.
Title: Re: Tiquionophist's Class Scheduler [1.2.0]
Post by: Umgah on May 31, 2022, 02:55 PM
Thank you for restoring this topic! I was thinking that I might need to do it myself :)
Title: Re: [Tool] Tiquionophist's Class Scheduler [1.2.0]
Post by: nobby on May 31, 2022, 03:46 PM
Thank-you so much for posting. This is an invaluable tool.

This needs to get integrated into the base game asap. One of the least fun parts of the game.
Title: Re: [Tool] Tiquionophist's Class Scheduler [1.2.0]
Post by: Umgah on May 31, 2022, 11:08 PM
Quote from: nobby on May 31, 2022, 03:46 PMThis needs to get integrated into the base game asap.
Unfortunately that tool can't be directly integrated into the game because it's written on different programming language and runtime (game is DotNet-based and this tool is Java-based). There are few possible things that we can implement but we do not have much resources for that.

So for now things are likely to stay as it is. I think it's not that hard to save your game, run this tool to modify the saved schedule and the load your game from the edited save file.
Title: Re: [Tool] Tiquionophist's Class Scheduler [1.2.0]
Post by: tiquionophist on Jun 01, 2022, 05:46 AM
Quote from: Umgah on May 31, 2022, 11:08 PM
Quote from: nobby on May 31, 2022, 03:46 PMThis needs to get integrated into the base game asap.
Unfortunately that tool can't be directly integrated into the game because it's written on different programming language and runtime (game is DotNet-based and this tool is Java-based). There are few possible things that we can implement but we do not have much resources for that.

So for now things are likely to stay as it is. I think it's not that hard to save your game, run this tool to modify the saved schedule and the load your game from the edited save file.

Agreed, frankly I'm not terribly interested in delving into HHS+'s codebase to work on a more direct integration. In the long term, it would be pretty straightforward from my side to expose a simple CLI which the game could invoke to generate schedules. I don't imagine the team will have the resources for that in the near future, but if it's ever something you're interested in do let me know.

And if anyone has ideas for lighter-weight ways to make the program easier to use I'd be happy to hear them :)
Title: Re: [Tool] Tiquionophist's Class Scheduler [1.2.0]
Post by: MindeKing on Jun 02, 2022, 06:55 PM
Whenever I try to launch the tool using the .exe from the .zip download, I only get an error window that says "Failed to launch JMV". And I can't seem to get the .jar file working either. I even reinstalled java to see if that would do anything, and it didn't.
However, it does seem that the .msi version works perfectly fine (but only when I installed it to Program Files. It gives me the same error message when I try installing it around my hhs folder).
I wish I knew if I was doing something wrong, but I can't find anything that hints toward that possibility. So if I'm not doing anything wrong, treat this as some sort of bug report?
Thank you for all your hard work, regardless.
Title: Re: [Tool] Tiquionophist's Class Scheduler [1.2.0]
Post by: Umgah on Jun 02, 2022, 11:38 PM
Found an interesting piece of software for integration between Java and DotNet http://jni4net.com/
However it's quite dated :(

So it's unlikely to be useful but still interesting.
Title: Re: [Tool] Tiquionophist's Class Scheduler [1.2.0]
Post by: tiquionophist on Jun 03, 2022, 08:02 PM
Quote from: MindeKing on Jun 02, 2022, 06:55 PMWhenever I try to launch the tool using the .exe from the .zip download, I only get an error window that says "Failed to launch JMV". And I can't seem to get the .jar file working either. I even reinstalled java to see if that would do anything, and it didn't.
However, it does seem that the .msi version works perfectly fine (but only when I installed it to Program Files. It gives me the same error message when I try installing it around my hhs folder).
I wish I knew if I was doing something wrong, but I can't find anything that hints toward that possibility. So if I'm not doing anything wrong, treat this as some sort of bug report?
Thank you for all your hard work, regardless.

Thanks for the report - not surprised that the .jar doesn't work since it will likely require a specific Java version (I build with 16.0.2 and you're likely to have 1.8 or 11 installed). The .zip does work for me and should be packaged with the same JVM as the .msi, but I'll do some more investigating and see if I can find any issues. Knowing that it may be installation location specific is useful, thanks!

I'll likely have a small release soon with a few tweaks and fixes which has a chance of inadvertently fixing the problem as dependencies are updated.
Title: Re: [Tool] Tiquionophist's Class Scheduler [1.4.0]
Post by: Anon888 on May 21, 2023, 12:22 PM
Please update for 1.10.5.5, it doesn't work anymore
Title: Re: [Tool] Tiquionophist's Class Scheduler [1.4.0]
Post by: ⚧ Squark on May 21, 2023, 02:54 PM
Quote from: Anon888 on May 21, 2023, 12:22 PMPlease update for 1.10.5.5, it doesn't work anymore
I've just found that it still works. At least, the Standalone Zip file does.
Title: Re: [Tool] Tiquionophist's Class Scheduler [1.4.0]
Post by: Anon888 on May 21, 2023, 06:02 PM
Quote from: ⚧ Squark on May 21, 2023, 02:54 PM
Quote from: Anon888 on May 21, 2023, 12:22 PMPlease update for 1.10.5.5, it doesn't work anymore
I've just found that it still works. At least, the Standalone Zip file does.
I also tried it with the 1.4.0 standalone zip, but I'm gonna retry and edit this message with the result, maybe it was a one-time error.

Edit 1:
It doesn't work. I even tried disabling all mods and making a new save, and it gives me a slightly different error, but still an error nonetheless.

This is the error without mods:
com.fasterxml.jackson.core.JsonParseException: Invalid UTF-8 middle byte 0x0 (at char #102, byte #-1)
at com.fasterxml.jackson.dataformat.xml.XmlFactory._initializeXmlReader(XmlFactory.java:734)
at com.fasterxml.jackson.dataformat.xml.XmlFactory._createParser(XmlFactory.java:600)
at com.fasterxml.jackson.dataformat.xml.XmlFactory._createParser(XmlFactory.java:30)
at com.fasterxml.jackson.core.JsonFactory.createParser(JsonFactory.java:1031)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3542)
at com.tiquionophist.io.SaveFileIO.read(SaveFileIO.kt:30)
at com.tiquionophist.ui.MenuBarKt$MenuBar$4$1$3$1$1.invokeSuspend(MenuBar.kt:122)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)
Caused by: com.ctc.wstx.exc.WstxIOException: Invalid UTF-8 middle byte 0x0 (at char #102, byte #-1)
at com.ctc.wstx.sr.StreamScanner.constructFromIOE(StreamScanner.java:653)
at com.ctc.wstx.sr.StreamScanner.loadMore(StreamScanner.java:1017)
at com.ctc.wstx.sr.StreamScanner.getNext(StreamScanner.java:770)
at com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:2096)
at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1180)
at com.fasterxml.jackson.dataformat.xml.XmlFactory._initializeXmlReader(XmlFactory.java:729)
... 12 more
Caused by: java.io.CharConversionException: Invalid UTF-8 middle byte 0x0 (at char #102, byte #-1)
at com.ctc.wstx.io.UTF8Reader.reportInvalidOther(UTF8Reader.java:318)
at com.ctc.wstx.io.UTF8Reader.read(UTF8Reader.java:208)
at com.ctc.wstx.io.ReaderSource.readInto(ReaderSource.java:88)
at com.ctc.wstx.io.BranchingReaderSource.readInto(BranchingReaderSource.java:57)
at com.ctc.wstx.sr.StreamScanner.loadMore(StreamScanner.java:1011)
... 16 more

This is the error with mods:
com.fasterxml.jackson.core.JsonParseException: Invalid UTF-8 start byte 0x9e (at char #32, byte #-1)
at com.fasterxml.jackson.dataformat.xml.XmlFactory._initializeXmlReader(XmlFactory.java:734)
at com.fasterxml.jackson.dataformat.xml.XmlFactory._createParser(XmlFactory.java:600)
at com.fasterxml.jackson.dataformat.xml.XmlFactory._createParser(XmlFactory.java:30)
at com.fasterxml.jackson.core.JsonFactory.createParser(JsonFactory.java:1031)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3542)
at com.tiquionophist.io.SaveFileIO.read(SaveFileIO.kt:30)
at com.tiquionophist.ui.MenuBarKt$MenuBar$4$1$3$1$1.invokeSuspend(MenuBar.kt:122)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)
Caused by: com.ctc.wstx.exc.WstxIOException: Invalid UTF-8 start byte 0x9e (at char #32, byte #-1)
at com.ctc.wstx.sr.StreamScanner.constructFromIOE(StreamScanner.java:653)
at com.ctc.wstx.sr.StreamScanner.loadMore(StreamScanner.java:1017)
at com.ctc.wstx.sr.StreamScanner.getNext(StreamScanner.java:770)
at com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:2096)
at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1180)
at com.fasterxml.jackson.dataformat.xml.XmlFactory._initializeXmlReader(XmlFactory.java:729)
... 12 more
Caused by: java.io.CharConversionException: Invalid UTF-8 start byte 0x9e (at char #32, byte #-1)
at com.ctc.wstx.io.UTF8Reader.reportInvalidInitial(UTF8Reader.java:307)
at com.ctc.wstx.io.UTF8Reader.read(UTF8Reader.java:192)
at com.ctc.wstx.io.ReaderSource.readInto(ReaderSource.java:88)
at com.ctc.wstx.io.BranchingReaderSource.readInto(BranchingReaderSource.java:57)
at com.ctc.wstx.sr.StreamScanner.loadMore(StreamScanner.java:1011)
... 16 more
Title: Re: [Tool] Tiquionophist's Class Scheduler [1.4.0]
Post by: TBBle on May 21, 2023, 09:26 PM
Quote from: tiquionophist on Jun 01, 2022, 05:46 AMAnd if anyone has ideas for lighter-weight ways to make the program easier to use I'd be happy to hear them :)

What about a HHS+ mod that outputs the current timetable as a string to be copied into the tool, and can take a string back from the tool to overwrite the timetable. That would isolate the tool from parsing the save-game format, at least.
Title: Re: [Tool] Tiquionophist's Class Scheduler [1.4.0]
Post by: barteke22 on May 21, 2023, 09:36 PM
The save format has changed from XML to SQL.  If you want to go back to the old format (which should fix this) you can:

1. Open hhs+exe.config and change save_useSQLiteSaves to False.
2. Run exe & load save.
3. Save to new slot, this save (and new games) should use the old format now.
Title: Re: [Tool] Tiquionophist's Class Scheduler [1.4.0]
Post by: dalzomo on May 22, 2023, 03:24 AM
Quote from: barteke22 on May 21, 2023, 09:36 PMThe save format has changed from XML to SQL.  If you want to go back to the old format (which should fix this) you can:

1. Open hhs+exe.config and change save_useSQLiteSaves to False.
2. Run exe & load save.
3. Save to new slot, this save (and new games) should use the old format now.
Aside from being able to use this tool, what are the pros and cons of one save format over the other?
Title: Re: [Tool] Tiquionophist's Class Scheduler [1.4.0]
Post by: Anon888 on May 22, 2023, 04:53 AM
Quote from: barteke22 on May 21, 2023, 09:36 PMThe save format has changed from XML to SQL.  If you want to go back to the old format (which should fix this) you can:

1. Open hhs+exe.config and change save_useSQLiteSaves to False.
2. Run exe & load save.
3. Save to new slot, this save (and new games) should use the old format now.
Yeah, I imagined it had to do with the change in save format from what the errors tell me, but I didn't know that I could change it. Now I'll try doing so and edit this message with the results, thanks in advance.

Edit 1:
It works, thanks
Title: Re: [Tool] Tiquionophist's Class Scheduler [1.5.0]
Post by: tiquionophist on May 25, 2023, 05:34 AM
Sorry for the slow update; the latest release 1.5.0 now supports the new SQLite save file format (in addition to the old XML one) so it should work with HHS+ 1.10.5 out of the box. Please let me know if you run into any issues!


Quote from: TBBle on May 21, 2023, 09:26 PM
Quote from: tiquionophist on Jun 01, 2022, 05:46 AMAnd if anyone has ideas for lighter-weight ways to make the program easier to use I'd be happy to hear them :)

What about a HHS+ mod that outputs the current timetable as a string to be copied into the tool, and can take a string back from the tool to overwrite the timetable. That would isolate the tool from parsing the save-game format, at least.

That would make my job easier :P I'm not terribly interested in writing my own mod for it (if that's even possible without diving into the game engine) but I'd be happy to integrate with something like this. But I did see (at a brief glance) that 1.10.5 also adds some more scheduling functionality so maybe this tool will be less and less necessary over time (which I'd be quite happy with).
Title: Re: [Tool] Tiquionophist's Class Scheduler [1.5.0]
Post by: TBBle on May 25, 2023, 01:24 PM
Quote from: tiquionophist on May 25, 2023, 05:34 AMThat would make my job easier :P I'm not terribly interested in writing my own mod for it (if that's even possible without diving into the game engine) but I'd be happy to integrate with something like this.

That's fair. I believe it is possible from VEE: before I posted I checked that we seem to be able to extract and set timetables and teacher/classroom assignments, (mostly?) without "GetPropByName", but I didn't actually test it.

Perhaps if I have some spare time (and no one gets to it first), I'll look closely at exactly what data your (awesome) tool uses from and to the save file, and see if I can knock-out a mod to dump/load that same data in some parsable text format. (This would also make life easier for anyone who might want to try a different approach to the problem, perhaps.)

No promises though. And honestly, I suspect SQLite-formatted save files means that such an approach isn't as huge a win as it is with XML saves. SQLite is widely and safely supported, and so any system changes that break code using it would likely break the mod too, so it more shifts the maintenance burden than eliminates it.
Title: Re: [Tool] Tiquionophist's Class Scheduler [1.5.0]
Post by: tiquionophist on May 27, 2023, 04:27 AM
Sounds good! If it's helpful, the XML properties my program looks at are listed in this file (https://github.com/tiquionophist/hhs-scheduler/blob/master/src/main/kotlin/com/tiquionophist/io/SaveData.kt), if you can decipher that - mainly just the subjects/classrooms for each class on day of the week, whether each subject "CanBeTaught", and the people who have associated "TeacherSubjects" (aka employed teachers) and their subject experience levels.

Quote from: TBBle on May 25, 2023, 01:24 PMNo promises though. And honestly, I suspect SQLite-formatted save files means that such an approach isn't as huge a win as it is with XML saves. SQLite is widely and safely supported, and so any system changes that break code using it would likely break the mod too, so it more shifts the maintenance burden than eliminates it.
Definitely agreed here, but just a note that even in the new format, SQLite is just a wrapper on a massive XML blob that still contains all the relevant data (previously the same blob was compressed and encoded in the top-level XML file). But I presume this is the start of a process of moving the actual data into SQLite which would definitely make processing it much more pleasant and standardized.
Title: Re: [Tool] Tiquionophist's Class Scheduler [1.5.0]
Post by: ⚧ Squark on Jun 24, 2023, 09:32 AM
This tool does not work with Lexville saves. It throws the following error:

Error: Invalid UTF-8 middle byte 0x0 (at char #102, byte#-1)
Title: Re: [Tool] Tiquionophist's Class Scheduler [1.5.0]
Post by: tiquionophist on Jun 27, 2023, 06:03 AM
Quote from: ⚧ Squark on Jun 24, 2023, 09:32 AMThis tool does not work with Lexville saves. It throws the following error:

Error: Invalid UTF-8 middle byte 0x0 (at char #102, byte#-1)

Thanks for the report. I'm not able to reproduce this on my own Lexville save in 1.10.5.7, can you share some more details? In particular, are you using version 1.5.0 (or .1 (https://github.com/tiquionophist/hhs-scheduler/releases/tag/v1.5.1) for extra error logging) and at what point do you get this error - importing or exporting the save file?
Title: Re: [Tool] Tiquionophist's Class Scheduler [1.5.0]
Post by: ⚧ Squark on Jun 27, 2023, 11:59 AM
Just downloaded 1.5.0 and now it's throwing a different error:
(I'm using the standalone version)

Error: java/sql/Driver

Hang on, going to try something. BRB
Nope. Might it be that I'm trying it on a previous existing save on 1.10.5.6 and not 1.10.5.7?

The jar version crashes before it even starts with a Java VM error. My Java is the latest version.
I don't particularly want to install the msi build.

Also tried starting a new game with only Lexville running.
Title: Re: [Tool] Tiquionophist's Class Scheduler [1.5.0]
Post by: GemGem on Jun 29, 2023, 02:16 PM
Quotejava.lang.NoClassDefFoundError: java/sql/Driver
   at java.base/java.lang.ClassLoader.defineClass1(Native Method)
   at java.base/java.lang.ClassLoader.defineClass(Unknown Source)
   at java.base/java.security.SecureClassLoader.defineClass(Unknown Source)
   at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(Unknown Source)
   at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(Unknown Source)
   at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(Unknown Source)
   at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source)
   at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(Unknown Source)
   at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
   at java.base/java.lang.Class.forName0(Native Method)
   at java.base/java.lang.Class.forName(Unknown Source)
   at java.base/java.lang.Class.forName(Unknown Source)
   at org.jetbrains.exposed.sql.Database$Companion.connect(Database.kt:204)
   at org.jetbrains.exposed.sql.Database$Companion.connect$default(Database.kt:195)
   at com.tiquionophist.io.SaveFileIO.openSqliteDb(SaveFileIO.kt:252)
   at com.tiquionophist.io.SaveFileIO.extractData(SaveFileIO.kt:55)
   at com.tiquionophist.io.SaveFileIO.read(SaveFileIO.kt:78)
   at com.tiquionophist.ui.MenuBarKt$MenuBar$4$1$3$1$1.invokeSuspend(MenuBar.kt:122)
   at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
   at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
   at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
   at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
   at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
   at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)
Caused by: java.lang.ClassNotFoundException: java.sql.Driver
   at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source)
   at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(Unknown Source)
   at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
   ... 24 more
Above error I got when trying to import from a save file.
I'm using the LexVille mod as well and the TeacherCompendium mod.
Title: Re: [Tool] Tiquionophist's Class Scheduler [1.5.0]
Post by: tiquionophist on Jul 01, 2023, 04:14 AM
Thanks for the detailed reports! This issue (which was from my release process stripping key dependencies, so I didn't notice it in my own builds) should be fixed in the latest release 1.6.0. I've tested from the release artifacts directly now, but let me know if there are still any issues.
Title: Re: [Tool] Tiquionophist's Class Scheduler [1.6.0]
Post by: ⚧ Squark on Jul 02, 2023, 02:00 AM
Quote from: tiquionophist on Jul 01, 2023, 04:14 AMThanks for the detailed reports! This issue (which was from my release process stripping key dependencies, so I didn't notice it in my own builds) should be fixed in the latest release 1.6.0. I've tested from the release artifacts directly now, but let me know if there are still any issues.
Thanks for that. It works now ^^
Title: Re: [Tool] Tiquionophist's Class Scheduler [1.6.0]
Post by: dalzomo on Nov 04, 2023, 05:19 AM
I have been using this with the latest releases and haven't had any apparent problems. What, if anything, should I do to eliminate the "checksum doesn't match" popup when loading the scheduler exported save though?
Title: Re: [Tool] Tiquionophist's Class Scheduler [1.6.0]
Post by: ⚧ Squark on Nov 05, 2023, 12:30 AM
The checksum error doesn't matter.
If you're using mods on the save that you run this tool on, that's what happens.

But if it happens with a modless base game then something doesn't quite match up with what the tool expects.