diff --git a/Assets/Scripts/GenerateDemoFiles.cs b/Assets/Scripts/GenerateDemoFiles.cs index cab121e2a65f02a85efb3a7e067ccd4ce20e3f46..c9a1350f93eafa1b1317bec62baa16790d3eee63 100644 --- a/Assets/Scripts/GenerateDemoFiles.cs +++ b/Assets/Scripts/GenerateDemoFiles.cs @@ -22,6 +22,7 @@ public static void GenerateAll() GenerateRiverStage, GenerateCanonBallStage2D, GenerateCanonBallStage3D, + GenerateSlingShotStage, }; foreach (Action action in DemoGeneration) @@ -37,6 +38,34 @@ public static void GenerateAll() } } + public static void GenerateSlingShotStage() + { + // Generate Stage + StageStatic.LoadNewStage + ( + id: 2, + category: "Demo Category", + name: "SlingShot", + scene: "RiverWorld", + description: "Find the correct velocity for the SlingShot to bounce once on the island within range, such that the projectile lands on the other side.", + local: false, + forcelocal: true + ); + + //// Set Solution + //StageStatic.stage.solution.ValidationSet = + // new List<SolutionRecorder.SubSolution> + // { new SolutionRecorder.SubSolution(new HashSet<string> { target_Id }, null, null, new LineFactHightDirectionComparer()) }; + + // Set Gadgets/ Scrolls + StageStatic.stage.AllowedGadgets = null; + StageStatic.stage.AllowedScrolls = new() { MMTConstants.ScrollRiver }; + + // Save + StageStatic.SetMode(StageStatic.Mode.Create); + StageStatic.stage.store(false, true); + } + public static void GenerateTreeStage() { // Params @@ -50,7 +79,8 @@ public static void GenerateTreeStage() name: "TechDemo A", scene: "RiverWorld", description: "Tree Stage", - local: false + local: false, + forcelocal: true ); // Populate Solution @@ -91,7 +121,8 @@ public static void GenerateRiverStage() name: "TechDemo B", scene: "RiverWorld", description: "River Stage", - local: false + local: false, + forcelocal: true ); // Populate Solution @@ -200,7 +231,8 @@ public static void GenerateCanonBallStage2D() name: "CanonBall 2D", scene: "RiverWorld", description: "CanonBall 2D Test", - local: false + local: false, + forcelocal: true ); // Populate Solution @@ -423,7 +455,8 @@ public static void GenerateCanonBallStage3D() name: "CanonBall 3D", scene: "RiverWorld", description: "CanonBall 3D Test", - local: false + local: false, + forcelocal: true ); // Populate Solution @@ -506,12 +539,12 @@ public static void GenerateCanonBallStage3D() #endregion CannonBallScroll CanonBallProblemCalculator3D calc = new(Walls, StartPos, StartVec, Gravity, Py_bounce, dim_G, dim_A, dim_B, StageStatic.stage.solution); + StageStatic.stage.solution.ExposedSolutionFacts.AddRange(calc.Result_FuncCall_Id); //StageStatic.stage.solution.Add( // for reference // new ListFact(calc.Result_FuncCall_Id.ToArray(), null, new OMS("Tuple((txt)x(t->t^)x(t^->fact))"), StageStatic.stage.solution), // out bool _, true, null, null //); - StageStatic.stage.solution.ExposedSolutionFacts.AddRange(calc.Result_FuncCall_Id); //string attacheFactURI = StageStatic.stage.solution.Add( // new AttachedPositionFunction(BallURI, calc.Result_FuncCall_Id.ToArray(), StageStatic.stage.solution), diff --git a/Assets/Scripts/InteractionEngine/FactHandling/Facts/Fact.cs b/Assets/Scripts/InteractionEngine/FactHandling/Facts/Fact.cs index 64fa2c0670c61dfd7f3902330010188f013c55c9..8cd02132e99ac9a7532e20f3fb52f3342d3fcae1 100644 --- a/Assets/Scripts/InteractionEngine/FactHandling/Facts/Fact.cs +++ b/Assets/Scripts/InteractionEngine/FactHandling/Facts/Fact.cs @@ -612,8 +612,8 @@ public static void MakeFact(List<Fact> ret, object payload, SOMDoc ServerDefinit if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(List<>)) ret.AddRange(BypassServer - ? DynamicListFact.MMTFactory((List<dynamic>)payload, ServerDefinition, SOMDoc.SOMDocType(type), BypassURI) - : DynamicListFact.MMTFactory((List<dynamic>)payload, ServerDefinition, SOMDoc.SOMDocType(type))); + ? DynamicListFact.MMTFactory(Enumerable.ToList<dynamic>((dynamic)payload), ServerDefinition, SOMDoc.SOMDocType(type), BypassURI) + : DynamicListFact.MMTFactory(Enumerable.ToList<dynamic>((dynamic)payload), ServerDefinition, SOMDoc.SOMDocType(type))); else if (type.IsAnonymousType()) // TODO? generic Fact return; @@ -637,15 +637,16 @@ public static List<Fact> MMTFactory(MMTFact ingredient) ParsingDictionary.parseFactDictionary[ingredient.getType()] .Invoke(ret, ingredient) .FastForward(); + + if (ret.Count != 0) + return ret; } - catch + catch(Exception ex) { + Debug.LogException(ex); Debug.Log($"Could not statically parse {nameof(MMTFact)} {nameof(ingredient)}. Using dynamic Fallback..."); } - if (ret.Count != 0) - return ret; - SOMDoc indirect_payload = ingredient.GetDefines(); //if (indirect_payload == null) diff --git a/Assets/Scripts/InteractionEngine/FactHandling/Facts/FunctionFact.cs b/Assets/Scripts/InteractionEngine/FactHandling/Facts/FunctionFact.cs index e6865dc5c0439974b66501c617b69ca3e23bea89..e46309f07a16049da35ce8c42bf6f4d37bcdec28 100644 --- a/Assets/Scripts/InteractionEngine/FactHandling/Facts/FunctionFact.cs +++ b/Assets/Scripts/InteractionEngine/FactHandling/Facts/FunctionFact.cs @@ -71,8 +71,10 @@ public FunctionCallFact(string func_id, string arg_func_id, (float t_0, float t_ this.arg_func_id = arg_func_id; this.Domain = Domain; - if (Function_args.Signature[0] != typeof(float) - || Function_args.Signature[1..] != Function.Signature[..^0]) + if (Function_args != null // is case when reading in Json + && (Function_args.Signature[0] != typeof(float) // takes in |R + || (Function_args.Signature[1..].SequenceEqual(Function.Signature[..^0]) // output equals input + && Function_args.Signature[^1] != typeof(object[])))) // if output is object array => types are concieled throw new ArgumentException( $"Signatures must match: Func<float, D> {nameof(arg_func_id)} and Func<D,R> {nameof(func_id)}!\n" + $"But where {Function_args.Signature} and {Function.Signature}."); @@ -84,8 +86,9 @@ public FunctionCallFact(FunctionFact Function, FunctionFact Function_args, (floa this.Function_args = Function_args; this.Domain = Domain; - if (Function_args.Signature[0] != typeof(float) - || Function_args.Signature[1..] != Function.Signature[..^0]) + if (Function_args.Signature[0] != typeof(float) // takes in |R + || (Function_args.Signature[1..].SequenceEqual(Function.Signature[..^0]) // output equals input + && Function_args.Signature[^1] != typeof(object[]))) // if output is object array => types are concieled throw new ArgumentException( $"Signatures must match: Func<float, D> {nameof(arg_func_id)} and Func<D,R> {nameof(func_id)}!\n" + $"But where {Function_args.Signature} and {Function.Signature}."); diff --git a/Assets/Scripts/InventoryStuff/ScrollDetails.cs b/Assets/Scripts/InventoryStuff/ScrollDetails.cs index 09de155b607f51e0f8b23cb7bf904abe2b41afba..4b8bc0b52180dfcacc8fa5eead4ddf2f508fdb43 100644 --- a/Assets/Scripts/InventoryStuff/ScrollDetails.cs +++ b/Assets/Scripts/InventoryStuff/ScrollDetails.cs @@ -15,11 +15,10 @@ public static ScrollDetails Instance get => _Instance; set { - if (_Instance == null) - _Instance = value; - else if (_Instance != value) - Destroy(value); + Destroy(_Instance); + + _Instance = value; } } private static ScrollDetails _Instance; diff --git a/Assets/Scripts/MMTServer/CommunicationProtocoll/MMTConstants.cs b/Assets/Scripts/MMTServer/CommunicationProtocoll/MMTConstants.cs index 3661ee345ad31788eda1e35467cf9cba8f221a50..268a1753516100f995e72939a1533d56521fbc50 100644 --- a/Assets/Scripts/MMTServer/CommunicationProtocoll/MMTConstants.cs +++ b/Assets/Scripts/MMTServer/CommunicationProtocoll/MMTConstants.cs @@ -128,6 +128,7 @@ public static class MMTConstants public const string ScrollCannonBall2D = "http://mathhub.info/FrameIT/frameworld?WBouncingScroll"; public const string ScrollCannonBall3D = "http://mathhub.info/FrameIT/frameworld?W3DBouncingScroll"; public const string ScrollCannonBallT3D = "http://mathhub.info/FrameIT/frameworld?T3DBouncingScroll"; + public const string ScrollRiver = "http://mathhub.info/FrameIT/frameworld?RiverScroll"; public static readonly IReadOnlyDictionary<string, Type> OMS_TO_TYPE = new Dictionary<string, Type>() { diff --git a/Assets/Scripts/MMTServer/CommunicationProtocoll/SOMDocs.cs b/Assets/Scripts/MMTServer/CommunicationProtocoll/SOMDocs.cs index 6c6eb188270afe078f89cf55c102da32fc91c894..5011c89eaefbf327fa5fc171988c41b37151ae98 100644 --- a/Assets/Scripts/MMTServer/CommunicationProtocoll/SOMDocs.cs +++ b/Assets/Scripts/MMTServer/CommunicationProtocoll/SOMDocs.cs @@ -483,7 +483,8 @@ protected internal override Type ToType(Type[] args, (string name, Type type)[] protected override LambdaExpression _GetLambdaExpression(LambdaExpression[] lambda_applicant, LambdaExpression[] lambda_arguments, ParameterExpression[] bound_params) { - ParameterExpression v = bound_params.FirstOrDefault(param => param.Name.Equals(name)); + // in case of ambiguity: latest entry *should* be bounded stronger + ParameterExpression v = bound_params.Reverse().FirstOrDefault(param => param.Name.Equals(name)); if (v == null) { Debug.LogErrorFormat("Unable to find {0} for {1} with name: {2}", nameof(FUN.Param), nameof(OMV), name); diff --git a/Assets/Scripts/StageStatic.cs b/Assets/Scripts/StageStatic.cs index 761e8afe1dbf6a72e3494c79aa560e47a0c7e97d..0db24b44640c6e836cacdae461903cef8629b306 100644 --- a/Assets/Scripts/StageStatic.cs +++ b/Assets/Scripts/StageStatic.cs @@ -244,9 +244,9 @@ public static StageErrorStruct Validate(string category, int id, string name, st ); } - public static StageErrorStruct LoadNewStage(string category, int id, string name, string description, string scene, bool local = true) + public static StageErrorStruct LoadNewStage(string category, int id, string name, string description, string scene, bool local = true, bool forcelocal = false) { - StageErrorStruct ret = Validate(category, id, name, description, scene, local); + StageErrorStruct ret = Validate(category, id, name, description, scene, forcelocal ? true : local); if (!ret.pass) return ret;