private void FillBuildingListByType(List <SmartEntity> list, BuildingType type) { switch (type) { case BuildingType.Any: { NodeList <BuildingNode> nodeList = this.entityController.GetNodeList <BuildingNode>(); for (BuildingNode buildingNode = nodeList.Head; buildingNode != null; buildingNode = buildingNode.Next) { list.Add((SmartEntity)buildingNode.Entity); } return; } case BuildingType.HQ: for (HQNode hQNode = this.HQNodeList.Head; hQNode != null; hQNode = hQNode.Next) { list.Add((SmartEntity)hQNode.Entity); } return; case BuildingType.Barracks: for (BarracksNode barracksNode = this.BarracksNodeList.Head; barracksNode != null; barracksNode = barracksNode.Next) { list.Add((SmartEntity)barracksNode.Entity); } return; case BuildingType.Factory: for (FactoryNode factoryNode = this.FactoryNodeList.Head; factoryNode != null; factoryNode = factoryNode.Next) { list.Add((SmartEntity)factoryNode.Entity); } return; case BuildingType.FleetCommand: for (FleetCommandNode fleetCommandNode = this.FleetCommandNodeList.Head; fleetCommandNode != null; fleetCommandNode = fleetCommandNode.Next) { list.Add((SmartEntity)fleetCommandNode.Entity); } return; case BuildingType.HeroMobilizer: for (TacticalCommandNode tacticalCommandNode = this.TacticalCommandNodeList.Head; tacticalCommandNode != null; tacticalCommandNode = tacticalCommandNode.Next) { list.Add((SmartEntity)tacticalCommandNode.Entity); } return; case BuildingType.ChampionPlatform: for (ChampionPlatformNode championPlatformNode = this.ChampionPlatformNodeList.Head; championPlatformNode != null; championPlatformNode = championPlatformNode.Next) { list.Add((SmartEntity)championPlatformNode.Entity); } return; case BuildingType.Housing: for (HousingNode housingNode = this.HousingNodeList.Head; housingNode != null; housingNode = housingNode.Next) { list.Add((SmartEntity)housingNode.Entity); } return; case BuildingType.Squad: for (SquadBuildingNode squadBuildingNode = this.SquadBuildingNodeList.Head; squadBuildingNode != null; squadBuildingNode = squadBuildingNode.Next) { list.Add((SmartEntity)squadBuildingNode.Entity); } return; case BuildingType.Starport: for (StarportNode starportNode = this.StarportNodeList.Head; starportNode != null; starportNode = starportNode.Next) { list.Add((SmartEntity)starportNode.Entity); } return; case BuildingType.DroidHut: for (DroidHutNode droidHutNode = this.DroidHutNodeList.Head; droidHutNode != null; droidHutNode = droidHutNode.Next) { list.Add((SmartEntity)droidHutNode.Entity); } return; case BuildingType.Wall: for (WallNode wallNode = this.WallNodeList.Head; wallNode != null; wallNode = wallNode.Next) { list.Add((SmartEntity)wallNode.Entity); } return; case BuildingType.Turret: for (TurretBuildingNode turretBuildingNode = this.TurretBuildingNodeList.Head; turretBuildingNode != null; turretBuildingNode = turretBuildingNode.Next) { list.Add((SmartEntity)turretBuildingNode.Entity); } return; case BuildingType.TroopResearch: for (OffenseLabNode offenseLabNode = this.OffenseLabNodeList.Head; offenseLabNode != null; offenseLabNode = offenseLabNode.Next) { list.Add((SmartEntity)offenseLabNode.Entity); } return; case BuildingType.DefenseResearch: for (DefenseLabNode defenseLabNode = this.DefenseLabNodeList.Head; defenseLabNode != null; defenseLabNode = defenseLabNode.Next) { list.Add((SmartEntity)defenseLabNode.Entity); } return; case BuildingType.Resource: for (GeneratorNode generatorNode = this.GeneratorNodeList.Head; generatorNode != null; generatorNode = generatorNode.Next) { list.Add((SmartEntity)generatorNode.Entity); } return; case BuildingType.Storage: for (StorageNode storageNode = this.StorageNodeList.Head; storageNode != null; storageNode = storageNode.Next) { list.Add((SmartEntity)storageNode.Entity); } return; case BuildingType.ShieldGenerator: for (ShieldGeneratorNode shieldGeneratorNode = this.ShieldGeneratorNodeList.Head; shieldGeneratorNode != null; shieldGeneratorNode = shieldGeneratorNode.Next) { list.Add((SmartEntity)shieldGeneratorNode.Entity); } return; case BuildingType.Clearable: for (ClearableNode clearableNode = this.ClearableNodeList.Head; clearableNode != null; clearableNode = clearableNode.Next) { list.Add((SmartEntity)clearableNode.Entity); } return; case BuildingType.Trap: for (TrapNode trapNode = this.TrapNodeList.Head; trapNode != null; trapNode = trapNode.Next) { list.Add((SmartEntity)trapNode.Entity); } return; case BuildingType.Cantina: for (CantinaNode cantinaNode = this.CantinaNodeList.Head; cantinaNode != null; cantinaNode = cantinaNode.Next) { list.Add((SmartEntity)cantinaNode.Entity); } return; case BuildingType.NavigationCenter: for (NavigationCenterNode navigationCenterNode = this.NavigationCenterNodeList.Head; navigationCenterNode != null; navigationCenterNode = navigationCenterNode.Next) { list.Add((SmartEntity)navigationCenterNode.Entity); } return; case BuildingType.ScoutTower: for (ScoutTowerNode scoutTowerNode = this.ScoutTowerNodeList.Head; scoutTowerNode != null; scoutTowerNode = scoutTowerNode.Next) { list.Add((SmartEntity)scoutTowerNode.Entity); } return; case BuildingType.Armory: for (ArmoryNode armoryNode = this.ArmoryNodeList.Head; armoryNode != null; armoryNode = armoryNode.Next) { list.Add((SmartEntity)armoryNode.Entity); } return; } Service.Logger.Warn("Unknown building type " + type); }
public bool HasConstructedBuilding(BuildingTypeVO reqBuilding) { int lvl = reqBuilding.Lvl; switch (reqBuilding.Type) { case BuildingType.HQ: for (HQNode hQNode = this.HQNodeList.Head; hQNode != null; hQNode = hQNode.Next) { if (GameUtils.GetBuildingEffectiveLevel((SmartEntity)hQNode.BuildingComp.Entity) >= lvl) { return(true); } } return(false); case BuildingType.Barracks: for (BarracksNode barracksNode = this.BarracksNodeList.Head; barracksNode != null; barracksNode = barracksNode.Next) { if (GameUtils.GetBuildingEffectiveLevel((SmartEntity)barracksNode.BuildingComp.Entity) >= lvl) { return(true); } } return(false); case BuildingType.Factory: for (FactoryNode factoryNode = this.FactoryNodeList.Head; factoryNode != null; factoryNode = factoryNode.Next) { if (GameUtils.GetBuildingEffectiveLevel((SmartEntity)factoryNode.BuildingComp.Entity) >= lvl) { return(true); } } return(false); case BuildingType.FleetCommand: for (FleetCommandNode fleetCommandNode = this.FleetCommandNodeList.Head; fleetCommandNode != null; fleetCommandNode = fleetCommandNode.Next) { if (GameUtils.GetBuildingEffectiveLevel((SmartEntity)fleetCommandNode.BuildingComp.Entity) >= lvl) { return(true); } } return(false); case BuildingType.HeroMobilizer: for (TacticalCommandNode tacticalCommandNode = this.TacticalCommandNodeList.Head; tacticalCommandNode != null; tacticalCommandNode = tacticalCommandNode.Next) { if (GameUtils.GetBuildingEffectiveLevel((SmartEntity)tacticalCommandNode.BuildingComp.Entity) >= lvl) { return(true); } } return(false); case BuildingType.ChampionPlatform: for (ChampionPlatformNode championPlatformNode = this.ChampionPlatformNodeList.Head; championPlatformNode != null; championPlatformNode = championPlatformNode.Next) { if (GameUtils.GetBuildingEffectiveLevel((SmartEntity)championPlatformNode.BuildingComp.Entity) >= lvl) { return(true); } } return(false); case BuildingType.Housing: for (HousingNode housingNode = this.HousingNodeList.Head; housingNode != null; housingNode = housingNode.Next) { if (GameUtils.GetBuildingEffectiveLevel((SmartEntity)housingNode.BuildingComp.Entity) >= lvl) { return(true); } } return(false); case BuildingType.Squad: for (SquadBuildingNode squadBuildingNode = this.SquadBuildingNodeList.Head; squadBuildingNode != null; squadBuildingNode = squadBuildingNode.Next) { if (GameUtils.GetBuildingEffectiveLevel((SmartEntity)squadBuildingNode.BuildingComp.Entity) >= lvl) { return(true); } } return(false); case BuildingType.Starport: for (StarportNode starportNode = this.StarportNodeList.Head; starportNode != null; starportNode = starportNode.Next) { if (GameUtils.GetBuildingEffectiveLevel((SmartEntity)starportNode.BuildingComp.Entity) >= lvl) { return(true); } } return(false); case BuildingType.DroidHut: for (DroidHutNode droidHutNode = this.DroidHutNodeList.Head; droidHutNode != null; droidHutNode = droidHutNode.Next) { if (GameUtils.GetBuildingEffectiveLevel((SmartEntity)droidHutNode.BuildingComp.Entity) >= lvl) { return(true); } } return(false); case BuildingType.Wall: for (WallNode wallNode = this.WallNodeList.Head; wallNode != null; wallNode = wallNode.Next) { if (GameUtils.GetBuildingEffectiveLevel((SmartEntity)wallNode.BuildingComp.Entity) >= lvl) { return(true); } } return(false); case BuildingType.Turret: for (TurretBuildingNode turretBuildingNode = this.TurretBuildingNodeList.Head; turretBuildingNode != null; turretBuildingNode = turretBuildingNode.Next) { if (turretBuildingNode.BuildingComp.BuildingType.UpgradeGroup == reqBuilding.UpgradeGroup && GameUtils.GetBuildingEffectiveLevel((SmartEntity)turretBuildingNode.BuildingComp.Entity) >= lvl) { return(true); } } return(false); case BuildingType.TroopResearch: for (OffenseLabNode offenseLabNode = this.OffenseLabNodeList.Head; offenseLabNode != null; offenseLabNode = offenseLabNode.Next) { if (GameUtils.GetBuildingEffectiveLevel((SmartEntity)offenseLabNode.BuildingComp.Entity) >= lvl) { return(true); } } return(false); case BuildingType.DefenseResearch: for (DefenseLabNode defenseLabNode = this.DefenseLabNodeList.Head; defenseLabNode != null; defenseLabNode = defenseLabNode.Next) { if (GameUtils.GetBuildingEffectiveLevel((SmartEntity)defenseLabNode.BuildingComp.Entity) >= lvl) { return(true); } } return(false); case BuildingType.Resource: for (GeneratorNode generatorNode = this.GeneratorNodeList.Head; generatorNode != null; generatorNode = generatorNode.Next) { if (generatorNode.BuildingComp.BuildingType.Currency == reqBuilding.Currency && GameUtils.GetBuildingEffectiveLevel((SmartEntity)generatorNode.BuildingComp.Entity) >= lvl) { return(true); } } return(false); case BuildingType.Storage: for (StorageNode storageNode = this.StorageNodeList.Head; storageNode != null; storageNode = storageNode.Next) { if (storageNode.BuildingComp.BuildingType.Currency == reqBuilding.Currency && GameUtils.GetBuildingEffectiveLevel((SmartEntity)storageNode.BuildingComp.Entity) >= lvl) { return(true); } } return(false); case BuildingType.Trap: for (TrapNode trapNode = this.TrapNodeList.Head; trapNode != null; trapNode = trapNode.Next) { if (GameUtils.GetBuildingEffectiveLevel((SmartEntity)trapNode.BuildingComp.Entity) >= lvl) { return(true); } } return(false); case BuildingType.Cantina: for (CantinaNode cantinaNode = this.CantinaNodeList.Head; cantinaNode != null; cantinaNode = cantinaNode.Next) { if (GameUtils.GetBuildingEffectiveLevel((SmartEntity)cantinaNode.BuildingComp.Entity) >= lvl) { return(true); } } return(false); case BuildingType.NavigationCenter: for (NavigationCenterNode navigationCenterNode = this.NavigationCenterNodeList.Head; navigationCenterNode != null; navigationCenterNode = navigationCenterNode.Next) { if (GameUtils.GetBuildingEffectiveLevel((SmartEntity)navigationCenterNode.BuildingComp.Entity) >= lvl) { return(true); } } return(false); case BuildingType.ScoutTower: for (ScoutTowerNode scoutTowerNode = this.ScoutTowerNodeList.Head; scoutTowerNode != null; scoutTowerNode = scoutTowerNode.Next) { if (GameUtils.GetBuildingEffectiveLevel((SmartEntity)scoutTowerNode.BuildingComp.Entity) >= lvl) { return(true); } } return(false); case BuildingType.Armory: for (ArmoryNode armoryNode = this.ArmoryNodeList.Head; armoryNode != null; armoryNode = armoryNode.Next) { if (GameUtils.GetBuildingEffectiveLevel((SmartEntity)armoryNode.BuildingComp.Entity) >= lvl) { return(true); } } return(false); } Service.Logger.Warn("Unknown reqBuilding type for level: " + reqBuilding.Uid); return(false); }
private GeneratorNode generateNode() { HashSet<GeneratorNode> spawnedNodes; HashSet<GeneratorNode> newNodes = new HashSet<GeneratorNode>(); int size = 0, atoms = 0; long timeBegin = Stopwatch.GetTimestamp(); // Takes each node and applies its decomposition foreach (GeneratorNode wn in m_nodes) { GeneratorNode wn2 = new GeneratorNode(); wn2.setGamma(wn.getDelta()); spawnedNodes = wn2.spawn(); foreach (GeneratorNode gn in spawnedNodes) { newNodes.Add(gn); } // Shortcut: as soon as one branch returns something, we skip the others if (spawnedNodes.Count > 0) { break; } } long timeEnd = Stopwatch.GetTimestamp(); System.Console.WriteLine("Finished producing the " + newNodes.Count + "nodes " + (timeEnd - timeBegin)); timeBegin = Stopwatch.GetTimestamp(); // Remember the new nodes m_nodes = newNodes; // Updates statistics about maximum number of nodes size = m_nodes.Count; if (size > m_maxNodes) { m_maxNodes = size; } // Updates statistics about total number of formulae size = 0; atoms = 0; foreach (GeneratorNode wn in m_nodes) { size += wn.getSize(); atoms += wn.getAtoms(); } if (size > m_maxFormulae) { m_maxFormulae = size; } if (atoms > m_maxAtoms) { m_maxAtoms = atoms; } // We remove nodes that don't contain any OPlus // (i.e., that don't tell us to do anything) // and check at the same time if at least one node is sound bool hasSound = false; foreach (GeneratorNode wn in m_nodes) { HashSet<OPlus> opluses = wn.getOPluses(); bool contains_element = false; foreach (OPlus op in opluses) { // Remove conditions that only assert path existence if (!op.getOperand().Equals(Operator.m_falseAtom) && !op.getOperand().Equals(Operator.m_trueAtom)) { contains_element = true; } } if (!contains_element) { m_nodes.Remove(wn); } else { if (wn.Sound) { hasSound = true; } } } // Can we produce a new message? if (m_nodes.Count == 0) { // No! return null; } // We remove all nodes whose OPluses are contradictory /*it = m_nodes.iterator(); while (it.hasNext()) { GeneratorNode wn = it.next(); if (wn.containsOPlusContradiction()) it.remove(); }*/ // Is there at least one remaining sound node? if (hasSound) { // Yes: then let's remove any unsound node foreach (GeneratorNode wn in m_nodes) { if (!wn.Sound) { m_nodes.Remove(wn); } } } timeEnd = Stopwatch.GetTimestamp(); System.Console.WriteLine("Finished pruning " + (timeEnd - timeBegin)); // Pick *one* of the nodes randomly long pickIndex = (long)System.Math.Round(new System.Random().NextDouble() * (double)(m_nodes.Count - 1)); int i = 0; GeneratorNode pickedNode = null; foreach (GeneratorNode gn in m_nodes) { if (i == pickIndex) { pickedNode = gn; break; } i++; } // Keep only the selected node for the next state m_nodes = new HashSet<GeneratorNode>(); m_nodes.Add(pickedNode); // Return the picked node return pickedNode; }
public int GetBuildingPurchasedQuantity(BuildingTypeVO building) { switch (building.Type) { case BuildingType.Invalid: Service.Logger.Warn("Invalid building type for count: " + building.Uid); return(0); case BuildingType.HQ: return(this.HQNodeList.CalculateCount()); case BuildingType.Barracks: return(this.BarracksNodeList.CalculateCount()); case BuildingType.Factory: return(this.FactoryNodeList.CalculateCount()); case BuildingType.FleetCommand: return(this.FleetCommandNodeList.CalculateCount()); case BuildingType.HeroMobilizer: return(this.TacticalCommandNodeList.CalculateCount()); case BuildingType.ChampionPlatform: { int num = 0; for (ChampionPlatformNode championPlatformNode = this.ChampionPlatformNodeList.Head; championPlatformNode != null; championPlatformNode = championPlatformNode.Next) { if (championPlatformNode.BuildingComp.BuildingType.UpgradeGroup == building.UpgradeGroup) { num++; } } return(num); } case BuildingType.Housing: return(this.HousingNodeList.CalculateCount()); case BuildingType.Squad: return(this.SquadBuildingNodeList.CalculateCount()); case BuildingType.Starport: return(this.StarportNodeList.CalculateCount()); case BuildingType.DroidHut: return(this.DroidHutNodeList.CalculateCount()); case BuildingType.Wall: return(this.WallNodeList.CalculateCount()); case BuildingType.Turret: { int num2 = 0; for (TurretBuildingNode turretBuildingNode = this.TurretBuildingNodeList.Head; turretBuildingNode != null; turretBuildingNode = turretBuildingNode.Next) { if (turretBuildingNode.BuildingComp.BuildingType.UpgradeGroup == building.UpgradeGroup) { num2++; } } return(num2); } case BuildingType.TroopResearch: return(this.OffenseLabNodeList.CalculateCount()); case BuildingType.DefenseResearch: return(this.DefenseLabNodeList.CalculateCount()); case BuildingType.Resource: { int num3 = 0; for (GeneratorNode generatorNode = this.GeneratorNodeList.Head; generatorNode != null; generatorNode = generatorNode.Next) { if (generatorNode.BuildingComp.BuildingType.Currency == building.Currency) { num3++; } } return(num3); } case BuildingType.Storage: { int num4 = 0; for (StorageNode storageNode = this.StorageNodeList.Head; storageNode != null; storageNode = storageNode.Next) { if (storageNode.BuildingComp.BuildingType.Currency == building.Currency) { num4++; } } return(num4); } case BuildingType.ShieldGenerator: { int num5 = 0; NodeList <BuildingNode> nodeList = this.entityController.GetNodeList <BuildingNode>(); for (BuildingNode buildingNode = nodeList.Head; buildingNode != null; buildingNode = buildingNode.Next) { if (buildingNode.BuildingComp.BuildingType.Type == BuildingType.ShieldGenerator) { num5++; } } return(num5); } case BuildingType.Rubble: return(0); case BuildingType.Trap: { int num6 = 0; for (TrapBuildingNode trapBuildingNode = this.TrapBuildingNodeList.Head; trapBuildingNode != null; trapBuildingNode = trapBuildingNode.Next) { if (trapBuildingNode.BuildingComp.BuildingType.UpgradeGroup == building.UpgradeGroup) { num6++; } } return(num6); } case BuildingType.Cantina: return(this.CantinaNodeList.CalculateCount()); case BuildingType.NavigationCenter: return(this.NavigationCenterNodeList.CalculateCount()); case BuildingType.ScoutTower: return(this.ScoutTowerNodeList.CalculateCount()); case BuildingType.Armory: return(this.ArmoryNodeList.CalculateCount()); } Service.Logger.Warn("Unknown building type for count: " + building.Uid); return(0); }
/** * Resets the watcher's state, i.e. considers the next message to be generated * as the first one. */ public void reset() { GeneratorNode wn = new GeneratorNode(); HashSet<Operator> hs = new HashSet<Operator>(); hs.Add(m_formulaToWatch); wn.setDelta(hs); m_nodes.Clear(); m_nodes.Add(wn); m_maxNodes = 1; m_maxFormulae = 0; m_maxAtoms = 0; }
protected static XMLDocument getSatisfyingMessage(GeneratorNode gn) { XMLDocument xd = new XMLDocument(); if (gn == null) { return xd; } HashSet<OPlus> opluses = gn.getOPluses(); foreach (OPlus op in opluses) { if (op.getOperand().Equals(Operator.m_trueAtom) || op.getOperand().Equals(Operator.m_falseAtom)) { // This only asserts that the path should exist continue; } xd.createPath(op.getQualifier(), op.getOperand().ToString()); } return xd; }
/** * Constructs a GeneratorNode2 based on another GeneratorNode2. (NOTE: deep or * shallow copy?) * * @param wn * The GeneratorNode2 of which to make a copy. */ public GeneratorNode(GeneratorNode wn) : this() { m_gamma = new HashSet<Operator>(); m_delta = new HashSet<Operator>(); m_opluses = new HashSet<OPlus>(); m_encounteredQualifiers = new HashSet<string>(); m_decomposedAForAll = wn.m_decomposedAForAll; m_sound = wn.m_sound; }
private void ShowModuleViewGUI() { GUI.Label(new Rect(10, 50, 160, 20), "Create Nodes:"); if (GUI.Button(new Rect(10, 70, 100, 20), "New Generator")) { GeneratorNode g = new GeneratorNode((int)scrollPos.x + 200, (int)scrollPos.y + 200); g.seed = Random.Range(-10000, 10000); settings.nodes.Add(g); windows.Add(new NodeWindow(g)); } if (GUI.Button(new Rect(120, 70, 100, 20), "New Operator")) { OperatorNode o = new OperatorNode((int)scrollPos.x + 200, (int)scrollPos.y + 200); settings.nodes.Add(o); windows.Add(new NodeWindow(o)); } if (GUI.Button(new Rect(230, 70, 100, 20), "New Macro")) { MacroNode m = new MacroNode((int)scrollPos.x + 200, (int)scrollPos.y + 200); settings.nodes.Add(m); windows.Add(new NodeWindow(m)); } scrollPos = GUI.BeginScrollView(new Rect(10, 95, this.position.width - 10, this.position.height - 105), scrollPos, scrollRect); BeginWindows(); foreach (NodeWindow n in windows) { // show the window Rect rect = n.Show(); // delete button if (!(n.node is OutputNode)) { if (GUI.Button(new Rect(rect.x + rect.width - 20, rect.y - 16, 20, 16), "x")) { toBeRemoved.Add(n); } } // input port buttons if (n.node.Inputs != null) { for (int i = 0; i < n.node.Inputs.Length; i++) { Rect input = new Rect(rect.x - 14, (rect.y + rect.height / 2 - 7) + i * 20f - (n.node.Inputs.Length - 1) * 20f / 2, 14, 14); if (!isConnecting) { if (GUI.Button(input, "")) { isConnecting = true; isInput = true; selectedNode = n.node; selectedPort = i; } } else { if (!isInput) { if (GUI.Button(input, "")) { n.node.Connect(selectedNode, i); n.UpdatePreview(); isConnecting = false; } } } // draw connections if (n.node.Inputs[i] != null) { DrawBezier(n.node.Inputs[i].Rect.ToRect(), input, n.connectionColor); } } } // output button if (n.node.HasOutput) { Rect output = new Rect(rect.x + rect.width - 2, rect.y + rect.height / 2 - 7, 14, 14); if (!isConnecting) { if (GUI.Button(output, "")) { isConnecting = true; isInput = false; selectedNode = n.node; } } else { if (isInput) { if (GUI.Button(output, "")) { selectedNode.Connect(n.node, selectedPort); UpdateNodeWindow(selectedNode); isConnecting = false; } } } } } EndWindows(); GUI.EndScrollView(); }
public HashSet<GeneratorNode> spawn(OperatorV op) { HashSet<GeneratorNode> spawnedSet, outSet = new HashSet<GeneratorNode>(); // Do for left node GeneratorNode wn = new GeneratorNode(this); Operator o2 = op.getLeftOperand(); wn.addToGamma(o2); o2 = op.getRightOperand(); wn.addToGamma(o2); spawnedSet = wn.spawn(); if (spawnedSet != null) { foreach (GeneratorNode gn in spawnedSet) { outSet.Add(gn); } } // Do for right node wn = new GeneratorNode(this); o2 = op.getRightOperand(); wn.addToGamma(o2); wn.addToDelta(op); spawnedSet = wn.spawn(); if (spawnedSet != null) { foreach (GeneratorNode gn in spawnedSet) { outSet.Add(gn); } } return outSet; }
public HashSet<GeneratorNode> spawn(OperatorX op) { HashSet<GeneratorNode> spawnedSet, outSet = new HashSet<GeneratorNode>(); GeneratorNode wn = new GeneratorNode(this); Operator o2 = op.getOperand(); wn.addToDelta(o2); spawnedSet = wn.spawn(); if (spawnedSet != null) { foreach (GeneratorNode gn in spawnedSet) { outSet.Add(gn); } } return outSet; }
public HashSet<GeneratorNode> spawn(OperatorImplies op) { HashSet<GeneratorNode> spawnedSet, outSet = new HashSet<GeneratorNode>(); // Do for right operand GeneratorNode wn = new GeneratorNode(this); Operator o2 = op.getRightOperand(); wn.addToGamma(o2); spawnedSet = wn.spawn(); if (spawnedSet != null) { foreach (GeneratorNode gn in spawnedSet) { outSet.Add(gn); } } // Do for right operand wn = new GeneratorNode(this); o2 = op.getLeftOperand().getNegated(); wn.addToGamma(o2.getNegatedNormalForm()); spawnedSet = wn.spawn(); if (spawnedSet != null) { foreach (GeneratorNode gn in spawnedSet) { outSet.Add(gn); } } // Do for both (NEW) wn = new GeneratorNode(this); o2 = op.getRightOperand(); wn.addToGamma(o2); o2 = op.getLeftOperand(); wn.addToGamma(o2); spawnedSet = wn.spawn(); if (spawnedSet != null) { foreach (GeneratorNode gn in spawnedSet) { outSet.Add(gn); } } return outSet; }
public HashSet<GeneratorNode> spawn(FOForAll op) { HashSet<GeneratorNode> spawnedSet, outSet = new HashSet<GeneratorNode>(); Atom x = op.getQuantifiedVariable(); string qualifier = op.getQualifier(); // Iterate over domain HashSet<Constant> oplus_domain = getOPlusDomain(qualifier); HashSet<Constant> domain = op.getDomain(); SubsetIterator<Constant> it; if (!m_encounteredQualifiers.Contains(qualifier)) { // We haven't decomposed a For All in the past, so we can // add elements to the message it = new SubsetIterator<Constant>(domain, oplus_domain); } else { // Otherwise, we stick to the elements we already have to // evaluate this quantifier it = new SubsetIterator<Constant>(oplus_domain); } m_encounteredQualifiers.Add(op.getQualifier()); m_decomposedAForAll = true; if (op.isPathNegation()) { // The quantifier asserts the absence of a path GeneratorNode wn = new GeneratorNode(this); OPlus opl = new OPlus(); opl.setQualifier(op.getQualifier()); opl.setOperand(Operator.m_falseAtom); if (!wn.addToOPluses(opl)) { // We can't add this OPlus to the current set. Contradiction! Return the empty set return new HashSet<GeneratorNode>(); } return wn.spawn(); } if (op.isPathAssertion()) { // In negated form, the quantifier may assert the existence of a path GeneratorNode wn = new GeneratorNode(this); OPlus opl = new OPlus(); opl.setQualifier(op.getQualifier()); opl.setOperand(Operator.m_trueAtom); if (!wn.addToOPluses(opl)) { // We can't add this OPlus to the current set. Contradiction! Return the empty set return new HashSet<GeneratorNode>(); } return wn.spawn(); } while (it.hasNext()) { GeneratorNode wn = new GeneratorNode(this); HashSet<Constant> subset = it.next(); foreach (Atom v in subset) { Operator o2 = op.getOperand(); Operator o3 = o2.evaluate(x, v); OPlus opl = new OPlus(qualifier, v); wn.addToGamma(o3); if (!wn.addToOPluses(opl)) { // Contradiction! Skip that branch continue; } } spawnedSet = wn.spawn(); if (spawnedSet != null) { foreach (GeneratorNode gn in spawnedSet) { outSet.Add(gn); } } } return outSet; }
public HashSet<GeneratorNode> spawn(FOExists op) { HashSet<GeneratorNode> outSet = new HashSet<GeneratorNode>(); Atom x = op.getQuantifiedVariable(); string qualifier = op.getQualifier(); if (m_encounteredQualifiers.Contains(qualifier)) { // We add something along a path where a ForAll has already // been evaluated: soundness is no longer guaranteed for this node m_sound = false; } if (op.isAnOPlus()) { // This is an OPlus; return a node with op transferred to the OPlus set GeneratorNode wn = new GeneratorNode(this); if (!wn.addToOPluses(op.toOPlus())) { // We can't add this OPlus to the current set. Contradiction! Return the empty set return new HashSet<GeneratorNode>(); } return wn.spawn(); } if (op.isPathAssertion()) { GeneratorNode wn = new GeneratorNode(); OPlus opl = new OPlus(); opl.setQualifier(op.getQualifier()); opl.setOperand(Operator.m_trueAtom); if (!wn.addToOPluses(opl)) { // We can't add this OPlus to the current set. Contradiction! Return the empty set return new HashSet<GeneratorNode>(); } return wn.spawn(); } // Iterate over domain //HashSet<Constant> oplus_domain = getOPlusDomain(qualifier); HashSet<Constant> domain = op.getDomain(); SubsetIterator<Constant> it = new SubsetIterator<Constant>(domain); //,oplus_domain while (it.hasNext()) { GeneratorNode wn = new GeneratorNode(this); HashSet<Constant> subset = it.next(); foreach (Atom v in subset) { Operator o2 = op .getOperand(); Operator o3 = o2.evaluate(x, v); if (!op.isPathAssertion()) { wn.addToGamma(o3); } OPlus opl = new OPlus(qualifier, v); if (!wn.addToOPluses(opl)) { // We can't add this OPlus to the current set. Contradiction! Skip that branch continue; } } HashSet<GeneratorNode> spawnedSet = wn.spawn(); if (spawnedSet != null) { foreach (GeneratorNode gn in spawnedSet) { outSet.Add(gn); } } } return outSet; }