Skip to content
Snippets Groups Projects
Commit f6e01130 authored by Marco Zimmer's avatar Marco Zimmer
Browse files

minor fixes, prototyped DynamiclySolvedEXP

parent 79d6fab7
No related branches found
No related tags found
No related merge requests found
Assets/Images/ScreenCapture.png

131 KiB | W: | H:

Assets/Images/ScreenCapture.png

131 B | W: | H:

Assets/Images/ScreenCapture.png
Assets/Images/ScreenCapture.png
Assets/Images/ScreenCapture.png
Assets/Images/ScreenCapture.png
  • 2-up
  • Swipe
  • Onion skin
File deleted
fileFormatVersion: 2
guid: 903066108a5d14444b8c9ffda790e310
timeCreated: 1471875076
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
...@@ -54,6 +54,8 @@ public class AnimationEventWithUris : UnityEvent<List<string>> { } ...@@ -54,6 +54,8 @@ public class AnimationEventWithUris : UnityEvent<List<string>> { }
//TODO? [SolutionManager, List<[HashSet<string>, FactComparer]>] //TODO? [SolutionManager, List<[HashSet<string>, FactComparer]>]
public static List<Fact> Solution = new List<Fact>(); public static List<Fact> Solution = new List<Fact>();
public static (FactOrganizer, List<(HashSet<string>, FactComparer)>) SolutionSet;
public static bool ServerRunning = true; public static bool ServerRunning = true;
public static string ServerAdress = "localhost:8085"; public static string ServerAdress = "localhost:8085";
......
...@@ -388,7 +388,7 @@ public override Boolean hasDependentFacts() { ...@@ -388,7 +388,7 @@ public override Boolean hasDependentFacts() {
} }
public override string[] getDependentFactIds() { public override string[] getDependentFactIds() {
return new string[] { }; ; return new string[] { };
} }
public override GameObject instantiateDisplay(GameObject prefab, Transform transform) { public override GameObject instantiateDisplay(GameObject prefab, Transform transform) {
...@@ -405,7 +405,7 @@ public override int GetHashCode() ...@@ -405,7 +405,7 @@ public override int GetHashCode()
protected override bool EquivalentWrapped(PointFact f1, PointFact f2) protected override bool EquivalentWrapped(PointFact f1, PointFact f2)
{ {
return f1.Point == f2.Point; return Math3d.IsApproximatelyEqual(f1.Point, f2.Point);
} }
} }
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
using System.Linq; using System.Linq;
using System; using System;
//TODO? PERF? (often inserts) SortedDict <-> Dict (often reads)
//TODO: MMT: move some functionality there //TODO: MMT: move some functionality there
//TODO: consequent!= samestep != dependent //TODO: consequent!= samestep != dependent
...@@ -547,6 +546,38 @@ public bool DynamiclySolved(List<Fact> MinimalSolution, out List<Fact> MissingEl ...@@ -547,6 +546,38 @@ public bool DynamiclySolved(List<Fact> MinimalSolution, out List<Fact> MissingEl
return MissingElements.Count == 0; return MissingElements.Count == 0;
} }
//TODO: repair
public bool DynamiclySolvedEXP(
(FactOrganizer solutionorganizer, List<(HashSet<string> subsolution, FactComparer comparer)> validationsets) MinimalSolution,
out List<List<string>> MissingElements,
out List<List<string>> Solutions)
{
MissingElements = new List<List<string>>();
Solutions = new List<List<string>>();
int MissingElementsCount = 0;
var activeList = FactDict.Values.Where(f => MetaInf[f.Id].active);
foreach (var ValidationSet in MinimalSolution.validationsets)
{
var part_minimal =
ValidationSet.subsolution.Select(URI => MinimalSolution.solutionorganizer[URI]);
var part_solution =
activeList.Where(active => part_minimal.Contains(active, ValidationSet.comparer.SetSearchRight()));
var part_missing =
part_minimal.Except(part_solution, ValidationSet.comparer.SetSearchLeft());
Solutions.Add(part_solution.Select(fact => fact.Id).ToList());
MissingElements.Add(part_missing.Select(fact => fact.Id).ToList());
MissingElementsCount += part_missing.Count();
}
return MissingElementsCount == 0;
}
} }
......
...@@ -24,17 +24,29 @@ void Start() ...@@ -24,17 +24,29 @@ void Start()
LineFact target = new LineFact(buttom.Id, top.Id, SolutionManager); LineFact target = new LineFact(buttom.Id, top.Id, SolutionManager);
Solution.Add(SolutionManager[SolutionManager.Add(target, out _, true)]); Solution.Add(SolutionManager[SolutionManager.Add(target, out _, true)]);
Fact.Clear(); Fact.Clear();
SolutionSet = (SolutionManager,
new List<(HashSet<string>, FactComparer)>
{ (new HashSet<string> { target.Id, buttom.Id }, new LineFactHightDirectionComparer()) });
} }
public static bool gameSolved() public static bool gameSolved()
{ {
bool solved = bool solved =
LevelFacts.DynamiclySolved(Solution, out _, out List<Fact> hits, FactComparer: new LineFactHightDirectionComparer()); LevelFacts.DynamiclySolved(Solution, out _, out List<Fact> hits, FactComparer: new LineFactHightDirectionComparer());
bool solvedEXP =
LevelFacts.DynamiclySolvedEXP(SolutionSet, out _, out List<List<string>> hitsEXP);
if (solved) if (solved)
foreach (var hit in hits) foreach (var hit in hits)
AnimateExistingFactEvent.Invoke(hit); AnimateExistingFactEvent.Invoke(hit);
if (solvedEXP)
foreach (var hitlist in hitsEXP)
foreach(var hit in hitlist)
AnimateExistingFactEvent.Invoke(LevelFacts[hit]);
return solved; return solved;
} }
......
...@@ -556,6 +556,12 @@ public static bool IsApproximatelyParallel(Vector3 vectorA, Vector3 vectorB, dou ...@@ -556,6 +556,12 @@ public static bool IsApproximatelyParallel(Vector3 vectorA, Vector3 vectorB, dou
< precission; < precission;
} }
//This function returns true if two Vector3s are approximately Equal
public static bool IsApproximatelyEqual(Vector3 vectorA, Vector3 vectorB, double precission = Math3d.vectorPrecission)
{
return (vectorA - vectorB).sqrMagnitude < precission;
}
//This function returns a point which is a projection from a point to a line segment. //This function returns a point which is a projection from a point to a line segment.
//If the projected point lies outside of the line segment, the projected point will //If the projected point lies outside of the line segment, the projected point will
//be clamped to the appropriate line edge. //be clamped to the appropriate line edge.
......
m_EditorVersion: 2020.3.15f2 m_EditorVersion: 2020.3.16f1
m_EditorVersionWithRevision: 2020.3.15f2 (6cf78cb77498) m_EditorVersionWithRevision: 2020.3.16f1 (049d6eca3c44)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment