public CHPoint?PointOfEntry2(ChemEObject InspectPreviousPosition) { CHPoint?retValue = null; for (int d = 0; d < InspectPreviousPosition.nextPosition.Count; d++) { if (InspectPreviousPosition.nextPosition.Keys.ElementAt(d).name == this.name) { retValue = InspectPreviousPosition.nextPosition.Values.ElementAt(d); } } return(retValue); }
public void AssignConnection(ChemEObject destination, CHPoint output, CHPoint input) { nextPosition.Add(destination, input); destination.previousPosition.Add(this, output); }
public void Move() { float sumProbabilities = 0; float sumGravityProbabilities = 0; float cumulativeLocMoveProbability = 0; float currentValue = 0; float randomNum = Random.Range(0f, 1f); possiblePositions = Position.CalculatePossiblePositions(this); possibleGravityPositions = Position.CalculatePossibleGravityPositions(this); for (int i = 0; i < possiblePositions.Count; i++) { sumProbabilities = sumProbabilities + possiblePositions.Values.ElementAt(i); } cumulativeLocMoveProbability = 0; if (possibleGravityPositions.Count > 0) { for (int i = 0; i < possibleGravityPositions.Count; i++) { sumGravityProbabilities = sumGravityProbabilities + possibleGravityPositions.Values.ElementAt(i); } for (int i = 0; i < possibleGravityPositions.Count; i++) { currentValue = possibleGravityPositions.Values.ElementAt(i) / sumGravityProbabilities; cumulativeLocMoveProbability = cumulativeLocMoveProbability + currentValue; } } cumulativeLocMoveProbability = 0; if (Position.QuantumSpace(this)) // Initiate movement if count > volume { for (int i = 0; i < possiblePositions.Count; i++) { currentValue = possiblePositions.Values.ElementAt(i) / sumProbabilities; cumulativeLocMoveProbability = cumulativeLocMoveProbability + currentValue; if (randomNum > cumulativeLocMoveProbability - currentValue && randomNum < cumulativeLocMoveProbability) { Position.Quantums.RemoveAll(item => item.Equals(this)); if (possiblePositions.Keys.ElementAt(i) is Drain) { Position = possiblePositions.Keys.ElementAt(i); } else { previousPosition = Position; Position = possiblePositions.Keys.ElementAt(i); // NOTE: Maybe there is a better solution, the problem is that // we don't know from which direction the quanta is comming // and PointOfExit and PointOfEntry are direction dependand // maybe the solution is to combine them together in ChemEObject // and call that function here (as well as eg in heatExchanger) entryPoint = null; entryPoint = position.PointOfExit2(previousPosition); if (entryPoint == null) { entryPoint = position.PointOfEntry2(previousPosition); } Position.Quantums.Add(this); } } } } }