// Broke it at some point, needs fixing public static void Main(string[] args) { var harmony = new Harmony("org.aragas.bannerlord.savesystem.fix"); harmony.Patch(LoadContextPatch.GetObjectWithIdMethod, postfix: new HarmonyMethod(typeof(LoadContextPatch), nameof(LoadContextPatch.GetObjectWithIdPostfix))); harmony.Patch(VariableLoadDataPatch.GetDataToUseMethod, transpiler: new HarmonyMethod(typeof(VariableLoadDataPatch), nameof(VariableLoadDataPatch.GetDataToUseTranspiler))); harmony.Patch(VariableLoadDataPatch.ReadMethod, transpiler: new HarmonyMethod(typeof(VariableLoadDataPatch), nameof(VariableLoadDataPatch.ReadTranspiler))); harmony.Patch(DefinitionContextPatch.TryGetTypeDefinitionMethod, transpiler: new HarmonyMethod(typeof(DefinitionContextPatch), nameof(DefinitionContextPatch.TryGetTypeDefinitionTranspiler))); harmony.Patch(DefinitionContextPatch.GetTypeDefinitionMethod, postfix: new HarmonyMethod(typeof(DefinitionContextPatch), nameof(DefinitionContextPatch.GetTypeDefinitionPostfix))); harmony.Patch(DefinitionContextPatch.GetClassDefinitionMethod, postfix: new HarmonyMethod(typeof(DefinitionContextPatch), nameof(DefinitionContextPatch.GetClassDefinitionPostfix))); harmony.Patch(DefinitionContextPatch.GetStructDefinitionMethod, prefix: new HarmonyMethod(typeof(DefinitionContextPatch), nameof(DefinitionContextPatch.GetStructDefinitionPrefix))); var saveName = "save_0021"; //string fileName = FilePaths.SavePath + saveName + ".sav"; var fileName = "D:\\GitHub\\SaveFixer\\" + saveName + ".sav"; ISaveDriver saveDriver = new FileDriver(fileName); var applicationVersion = saveDriver.LoadMetaData().GetApplicationVersion(); if (applicationVersion.Major <= 1 && applicationVersion.Minor <= 4 && applicationVersion.Revision < 2) { saveDriver = new OldFileDriver(fileName); } var loadResult = SaveManager.Load(saveDriver); Debug.Assert(loadResult.Successful); }
public void Test_RunSequenceTask_WithoutBuiltinDriver() { const string input = "train-sets/sequencespan_data"; const int bits = 24; const int passes = 4; string vwargs = $"-k -c -b {bits} --invariant --passes {passes} --search_rollout none --search_task sequencespan --search 7 --holdout_off"; VowpalWabbit rawvw = new VowpalWabbit(vwargs); uint GetLabel(VowpalWabbitExample ex) => ex.GetPrediction(rawvw, VowpalWabbitPredictionType.Multiclass); void RunSearchPredict(Multiline multiline) { // Parse the examples explicitly, because there is no easy way to get multiple predictions spread // across multiple input examples in non-ADF/LDF mode // TPrediction rawvw.Predict(ml, TPredictionFactory); // << There does not exist an appropriate one for search // Mostly because the infrastructure is not there to pull out // predictions from multiple examples. List <VowpalWabbitExample> multiex = new List <VowpalWabbitExample>(); try { foreach (string line in multiline) { multiex.Add(rawvw.ParseLine(line)); } rawvw.Predict(multiex); uint[] labels = multiex.Select(GetLabel).ToArray(); CollectionAssert.AreEqual(new uint[] { 2, 1, 1, 2, 2, 1, 6, 7, 7, 7, 7, 1, 6, 4, 1 }, labels); } finally { foreach (VowpalWabbitExample ex in multiex) { rawvw.ReturnExampleToPool(ex); } } } using (FileDriver driver = new FileDriver(input)) { int remainingPasses = passes; do { driver.ForEachMultiline(rawvw.Learn); rawvw.EndOfPass(); driver.Reset(); } while (remainingPasses-- > 0); driver.Reset(); driver.ForEachMultiline(RunSearchPredict); } rawvw.Dispose(); }