public Dictionary <int, StructuredAlias> .ValueCollection generateAliasOnTheFly() { mainMap = ParameterManager.Instance.MapToPlay; gridType = ParameterManager.Instance.GridType; SimilarMapsQueue = new SimplePriorityQueue <TileObject[, ]>(); K_CollisionSet = MapEvaluator.BuildKCollisionVec(mainMap, gridType, ParameterManager.Instance.StartCell, Mathf.Max(ParameterManager.Instance.minStepsSolution, ParameterManager.Instance.maxStepsSolution)); GenerateAndTestAliasMaps(); Dictionary <int, StructuredAlias> dic = new Dictionary <int, StructuredAlias>(); int i = UnityEngine.Random.Range(3, 7); //try to change while (i > 0) { dic.Add(i, new StructuredAlias(SimilarMapsQueue.Dequeue())); i--; } return(dic.Values); }
public void CollabGameGeneration() { mainMap = ParameterManager.Instance.MapToPlay; gridType = ParameterManager.Instance.GridType; SimilarMapsQueue = new SimplePriorityQueue <TileObject[, ]>(); K_CollisionSet = MapEvaluator.BuildKCollisionVec(mainMap, gridType, ParameterManager.Instance.StartCell, Mathf.Max(ParameterManager.Instance.minStepsSolution, ParameterManager.Instance.maxStepsSolution)); if (ParameterManager.Instance.isOptimizerOn) { List <TileObject[, ]> alises = new List <TileObject[, ]>(); BaseAliasCollisionMask = getMainMapKMaxMinCells(mainMap, gridType, ParameterManager.Instance.minStepsSolution, ParameterManager.Instance.minStepsSolution, ParameterManager.Instance.StartCell, 0f); int experimentsNum = 1; while (experimentsNum > 0) { foreach (var a in AliasGeneratorManager.Instance.GetComponent <AliasGameEvaluator>().AliasGameOptimizerHandler()) { SimilarMapsQueue.Enqueue(a.Value.AliasMap, a.Value.similarityDistance); } experimentsNum--; } } else { GenerateAndTestAliasMaps(); } int i = 0; Vector2Int startMainMap = ParameterManager.Instance.StartCell; TileObject[,] tmpStrAlias; while (i < ParameterManager.Instance.aliasNum) { if (ParameterManager.Instance.considerSimilar) { float dst = SimilarMapsQueue.GetPriority(SimilarMapsQueue.First()); tmpStrAlias = SimilarMapsQueue.Dequeue(); Utility.renderAliasOnUI(AliasDragAreas[0].GetChild(0).GetComponent <RectTransform>(), ParameterManager.Instance.GridType, new StructuredAlias(tmpStrAlias, startMainMap, ParameterManager.Instance.EndCell, dst), AliasPrefab, true); i++; } if (ParameterManager.Instance.considerNovelty && i < ParameterManager.Instance.aliasNum) { tmpStrAlias = SimilarMapsQueue.Last(); float dst = SimilarMapsQueue.GetPriority(tmpStrAlias); SimilarMapsQueue.Remove(tmpStrAlias); Utility.renderAliasOnUI(AliasDragAreas[0].GetChild(0).GetComponent <RectTransform>(), ParameterManager.Instance.GridType, new StructuredAlias(tmpStrAlias, startMainMap, ParameterManager.Instance.EndCell, dst), AliasPrefab, true); i++; } } i = 0; while (SimilarMapsQueue.Count > 0 && i < BatchAliasNumber) { float dst = SimilarMapsQueue.GetPriority(SimilarMapsQueue.First()); tmpStrAlias = SimilarMapsQueue.Dequeue(); Utility.renderAliasOnUI(AliasDragAreas[1].GetChild(0).GetComponent <RectTransform>(), ParameterManager.Instance.GridType, new StructuredAlias(tmpStrAlias, startMainMap, ParameterManager.Instance.EndCell, dst), AliasPrefab, true); i++; } i = 0; while (SimilarMapsQueue.Count > 0 && i < BatchAliasNumber) { tmpStrAlias = SimilarMapsQueue.Last(); float dst = SimilarMapsQueue.GetPriority(tmpStrAlias); SimilarMapsQueue.Remove(tmpStrAlias); Utility.renderAliasOnUI(AliasDragAreas[2].GetChild(0).GetComponent <RectTransform>(), ParameterManager.Instance.GridType, new StructuredAlias(tmpStrAlias, startMainMap, ParameterManager.Instance.EndCell, dst), AliasPrefab, true); i++; } //reset horizontal and vertical bars if exists ScrollRect sR = AliasDragAreas[0].GetComponent <ScrollRect>(); if (sR != null) { Scrollbar hSb = sR.horizontalScrollbar; Scrollbar vSb = sR.verticalScrollbar; if (hSb != null) { hSb.value = .99f; } if (vSb != null) { vSb.value = .99f; } } gameObject.GetComponent <AliasGameEvaluator>().AliasGameEvaluatorHandler(); }