public static Path FindPathToDestination(IJ currentNodeIndex, IJ targetNodeIndex, EPathfindingAlgorithm algorithm = EPathfindingAlgorithm.AStar, bool optimised = true) { var pathfinderToUse = _currentAlgorithms [algorithm]; return(pathfinderToUse.FindPathToDestination(currentNodeIndex, targetNodeIndex, optimised)); }
static void Main(string[] args) { IK f = new A(); f.methodK(); IJ c = (IJ)f; c.methodJ(); c.methodK(); IC j = (IC)c; j.methodC(); j.methodE(); j.methodJ(); j.methodK(); A a = (A)j; a.methodA(); a.methodB(); a.methodC(); a.methodD(); a.methodE(); a.methodJ(); a.methodK(); }
public static Path FindPathToDestination(MapController map, IJ currentNodeIndex, IJ targetNodeIndex, EPathfindingAlgorithm algorithm = EPathfindingAlgorithm.AStar) { var pathfinderToUse = _currentAlgorithms[algorithm]; return(pathfinderToUse.FindPathToDestination(currentNodeIndex, targetNodeIndex, map)); }
public void add(int i, int j) { if (i > j) { int temp; temp = j; j = i; i = temp; } int max = Math.Max(i, j); I.Add(i); J.Add(j); IJ.InsertRange(I.Count() - 1, new List <int> { i, j }); int count = H.Count; for (int k = 0; k <= max - count; k++) { H.Add(-1); } L.Add(H[i]); H[i] = I.Count - 1; }
public static bool IsKeyTopHeavy(IJL key) { IJ key_diff = new IJ(key.i + 2, key.j - 2); int rem_i = key_diff.i % 6; int rem_j = ((3 * key_diff.j) - key_diff.i) % 12; return((rem_i == 0) && (rem_j == 0)); }
public static bool operator !=(object obj, IJ a) { if (!(obj is IJ)) { return(true); } IJ other = (IJ)obj; return((a.i != other.i) || (a.j != other.j)); }
public static bool operator ==(object obj, IJ a) { if (!(obj is IJ)) { return(false); } IJ other = (IJ)obj; return((a.i == other.i) && (a.j == other.j)); }
public override bool Equals(object obj) { if (!(obj is IJ)) { return(false); } IJ other = (IJ)obj; return((i == other.i) && (j == other.j)); }
private ImmutableList <Tuple <FhirDateTime, FhirDecimal> > Convert_J( IJ value) { return(value.Value .Select( i => new Tuple <FhirDateTime, FhirDecimal>( i.t_IndexElement, i.Value)) .ToImmutableList()); }
private Vector2[] IJTo6x6UVs(IJ ij) { float fi = (float)ij.i; float fj = (float)ij.j; return(new Vector2[] { new Vector2(fi / 6f, fj / 6f), new Vector2(fi / 6f, (fj + 1) / 6f), new Vector2((fi + 1) / 6f, (fj + 1) / 6f), new Vector2((fi + 1) / 6f, fj / 6f) }); }
void OY(IJ II, IJ JJ, Graphics g) // построение оси OY { g.DrawLine(Pens.LightBlue, II2(0), JJ(y1), II2(0), JJ(y2)); double h1 = HH(y1, y2); int k1 = (int)Math.Round(y1 / h1) - 1; int k2 = (int)Math.Round(y2 / h1); int Digits = GetDigits(Math.Abs(y2 - y1)); aFont = new Font("Arial", 14, FontStyle.Bold); for (int i = k1; i <= k2; i++) { g.DrawLine(MyPen, II2(0) - 7, JJ(i * h1), II2(0) + 7, JJ(i * h1)); string s = Convert.ToString(Math.Round(h1 * i, Digits)); g.DrawString(s, aFont, Brushes.Black, II2(0), JJ(i * h1) - 2); } }
public void MyDraw(IJ II, IJ JJ, Graphics g) { if (g != null) { g.Clear(Color.White); aFont = new Font("Arial", 10, FontStyle.Bold); OX(II, JJ, g); OY(II, JJ, g); aFont.Dispose(); if (parser.topOp != null) { // сам график double h = (x2 - x1) / n; for (int i = 1; i < n; i++) { if (Math.Abs(F(x1 + (i - 1) * h) - F(x1 + (i - 0) * h)) < 10) { if ((F2(x1 + (i - 1) * h, x1 + i * h) || (Math.Abs(JJ(F(x1 + i * h)) - JJ(F(x1 + (i - 1) * h))) < 10))) { g.DrawLine(MyPen, II(x1 + (i - 1) * h), JJ(F(x1 + (i - 1) * h)), II(x1 + i * h), JJ(F(x1 + i * h))); } } } // производная(центральная разность) if (fFunc == 0) { h = (x2 - x1) / n; double oldx, oldyt; double x = x1; double yt = (F(x + h) - F(x - h)) / (2 * h); // центральная разность for (int i = 2; i <= n; i++) { oldx = x; oldyt = yt; x += h; yt = (F(x + h) - F(x - h)) / (2 * h); // центральная разность if ((F2(x - h, x + h)) || (Math.Abs(JJ(yt) - JJ(oldyt)) < 10)) { if (Math.Abs(yt - oldyt) < 10) { g.DrawLine(MyPen2, II(oldx) - 2, JJ(oldyt) - 2, II(x) - 2, JJ(yt) - 2); } } } } } } }
public void ApplyHeightMap(float[,] heightMap, IJ offsets, int resolutionCoef) { _selfTerrain.terrainData.size = new Vector3(Dimension, _maxHeight, Dimension); _selfTerrain.terrainData.heightmapResolution = Dimension; for (int i = 0; i < heightMap.GetLength(0); i++) { for (int j = 0; j < heightMap.GetLength(0); j++) { _heightMap [i + offsets.I, j + offsets.J] = heightMap [i, j]; } } _selfTerrain.terrainData.SetHeightsDelayLOD(0, 0, _heightMap); _maxHeight += 0.1f; }
void OX(IJ II, IJ JJ, Graphics g) // построение оси OX { g.DrawLine(Pens.LightBlue, II(x1), JJ2(0), II(x2), JJ2(0)); double h1 = HH(x1, x2); int k1 = (int)Math.Round(x1 / h1) - 1; int k2 = (int)Math.Round(x2 / h1); byte Digits = GetDigits(Math.Abs(x2 - x1)); aFont = new Font("Arial", 14, FontStyle.Bold); for (int i = k1; i <= k2; i++) { g.DrawLine(MyPen, II(i * h1), JJ2(0) - 7, II(i * h1), JJ2(0) + 7); string s = Convert.ToString(Math.Round(h1 * i, Digits)); g.DrawString(s, aFont, Brushes.Black, II(i * h1), JJ2(0) - 19); } }
public IDayProbableCases Calculate( It t, II I, IJ J, IQ Q, IR R) { return(new C19M.M.C.A.Gumel2004.Classes.Results.DayProbableCases.DayProbableCases( t.Value.Select( w => new C19M.M.C.A.Gumel2004.Classes.Calculations.DayProbableCases.DayProbableCases_ResultElement_Calculation().Calculate( w, I, J, Q, R)) .ToImmutableList())); }
public IDayDiseaseInducedDeaths Calculate( It t, C19M.M.C.A.Gumel2004.Interfaces.Parameters.DiseaseInducedDeathRateSymptomaticIndividuals.Id d_1, C19M.M.C.A.Gumel2004.Interfaces.Parameters.DiseaseInducedDeathRateIsolatedIndividuals.Id d_2, II I, IJ J) { return(new C19M.M.C.A.Gumel2004.Classes.Results.DayDiseaseInducedDeaths.DayDiseaseInducedDeaths( t.Value.Select( w => new C19M.M.C.A.Gumel2004.Classes.Calculations.DayDiseaseInducedDeaths.DayDiseaseInducedDeaths_ResultElement_Calculation().Calculate( w, d_1, d_2, I, J)) .ToImmutableList())); }
void OY(IJ II, IJ JJ, Graphics g) { g.DrawLine(Pens.Black, II(0), JJ(y1), II(0), JJ(y2)); double h1 = HH(y1, y2); int k1 = (int)Math.Round(y1 / h1) - 1; int k2 = (int)Math.Round(y2 / h1); int Digits = GetDigits(Math.Abs(y2 - y1)); for (int i = k1; i <= k2; i++) { g.DrawLine(MyPen2, II(0) - 7, JJ(i * h1), II(0) + 7, JJ(i * h1)); for (int j = 1; j <= 9; j++) { g.DrawLine(MyPen2, II(0) - 3, JJ(i * h1 + j * h1 / 10), II(0) + 3, JJ(i * h1 + j * h1 / 10)); } string s = Convert.ToString(Math.Round(h1 * i, Digits)); g.DrawString(s, aFont, Brushes.Black, II(0) + 5, JJ(i * h1) - 5); } }
void OX(IJ II, IJ JJ, Graphics g) { g.DrawLine(Pens.Black, II(x1), JJ(0), II(x2), JJ(0)); double h1 = HH(x1, x2); int k1 = (int)Math.Round(x1 / h1) - 1; int k2 = (int)Math.Round(x2 / h1); byte Digits = GetDigits(Math.Abs(x2 - x1)); for (int i = k1; i <= k2; i++) { g.DrawLine(MyPen2, II(i * h1), JJ(0) - 7, II(i * h1), JJ(0) + 7); for (int j = 1; j <= 9; j++) { g.DrawLine(MyPen2, II(i * h1 + j * h1 / 10), JJ(0) - 3, II(i * h1 + j * h1 / 10), JJ(0) + 3); } string s = Convert.ToString(Math.Round(h1 * i, Digits)); g.DrawString(s, aFont, Brushes.Black, II(i * h1) - 5, JJ(0) - 13); } }
public IDayDiseaseInducedDeaths_ResultElement Calculate( FhirDateTime t_IndexElement, C19M.M.C.A.Gumel2004.Interfaces.Parameters.DiseaseInducedDeathRateSymptomaticIndividuals.Id d_1, C19M.M.C.A.Gumel2004.Interfaces.Parameters.DiseaseInducedDeathRateIsolatedIndividuals.Id d_2, II I, IJ J) { return(new C19M.M.C.A.Gumel2004.Classes.ResultElements.DayDiseaseInducedDeaths.DayDiseaseInducedDeaths_ResultElement( t_IndexElement, new FhirDecimal( d_1.Value.Value.Value * I.GetElementAtAsdecimal( t_IndexElement) + d_2.Value.Value.Value * J.GetElementAtAsdecimal( t_IndexElement)))); }
public IDayProbableCases_ResultElement Calculate( FhirDateTime t_IndexElement, II I, IJ J, IQ Q, IR R) { return(new C19M.M.C.A.Gumel2004.Classes.ResultElements.DayProbableCases.DayProbableCases_ResultElement( t_IndexElement, new FhirDecimal( I.GetElementAtAsdecimal( t_IndexElement) + J.GetElementAtAsdecimal( t_IndexElement) + Q.GetElementAtAsdecimal( t_IndexElement) + R.GetElementAtAsdecimal( t_IndexElement)))); }
public IJL(IJ ij, int l) { this.i = ij.i; this.j = ij.j; this.l = l; }
public IJL(IJ ij) { this.i = ij.i; this.j = ij.j; this.l = 0; }
public IJ(IJ ij) { this.i = ij.i; this.j = ij.j; }
public Path FindPathToDestination(IJ currentNodeIndex, IJ targetNodeIndex, MapController mapGenerator) { var map = mapGenerator.CurrrentMapAsMatrix; Node startNode = map[currentNodeIndex.I, currentNodeIndex.J]; Node targetNode = map[targetNodeIndex.I, targetNodeIndex.J]; List <Node> openSet = new List <Node>(); HashSet <Node> closedSet = new HashSet <Node>(); openSet.Add(startNode); var iterator = 0; while (openSet.Count > 0) { if (iterator > 30) { return(FindPathToDestination(currentNodeIndex, closedSet.Last().GridPosition, mapGenerator)); } Node node = openSet[0]; for (int i = 1; i < openSet.Count; i++) { if (openSet[i].FCost < node.FCost || openSet[i].FCost == node.FCost) { if (openSet[i].HCost < node.HCost) { node = openSet[i]; } } } openSet.Remove(node); closedSet.Add(node); if (node == targetNode) { var t = RetracePath(startNode, targetNode); return(t); } var neighbours = mapGenerator.GetNeighbours(node); for (int i = 0; i < neighbours.Length; i++) { if (neighbours[i] == null) { continue; } var ignored = _ignoredNodeTypes.Any(p => p == neighbours[i].CurrentCellType); if (ignored || closedSet.Contains(neighbours[i])) { continue; } int newCostToNeighbour = node.GCost + mapGenerator.GetDistance(node, neighbours[i]); if (newCostToNeighbour < neighbours[i].GCost || !openSet.Contains(neighbours[i])) { neighbours[i].GCost = newCostToNeighbour; neighbours[i].HCost = mapGenerator.GetDistance(neighbours[i], targetNode); neighbours[i].Parent = node; iterator++; if (!openSet.Contains(neighbours[i])) { openSet.Add(neighbours[i]); } } } } return(new Path()); }
public Path FindPathToDestination(IJ currentNodeIndex, IJ targetNodeIndex, bool optimised = true) { var map = Game.Instance.CurrentMap.CurrentMapAsMatrix; Node startNode = map [currentNodeIndex.I, currentNodeIndex.J]; Node targetNode = map [targetNodeIndex.I, targetNodeIndex.J]; List <Node> openSet = new List <Node> (); HashSet <Node> closedSet = new HashSet <Node> (); var currentMap = Game.Instance.CurrentMap; openSet.Add(startNode); var iterator = 0; while (openSet.Count > 0) { if (optimised && iterator > 100) { return(FindPathToDestination(currentNodeIndex, closedSet.Last().GridPosition)); } Node node = openSet [0]; for (int i = 1; i < openSet.Count; i++) { if (openSet [i].FCost < node.FCost || openSet [i].FCost == node.FCost) { if (openSet [i].HCost < node.HCost) { node = openSet [i]; } } } openSet.Remove(node); closedSet.Add(node); if (node == targetNode) { var t = RetracePath(startNode, targetNode); return(t); } foreach (Node neighbour in currentMap.GetNeighbours(node, Vector2.one)) { var ignored = _ignoredNodeTypes.Any(p => p == neighbour.CurrentCellType); if (ignored || closedSet.Contains(neighbour)) { continue; } int newCostToNeighbour = node.GCost + currentMap.GetDistance(node, neighbour); if (newCostToNeighbour < neighbour.GCost || !openSet.Contains(neighbour)) { neighbour.GCost = newCostToNeighbour; neighbour.HCost = currentMap.GetDistance(neighbour, targetNode); neighbour.Parent = node; iterator++; if (!openSet.Contains(neighbour)) { openSet.Add(neighbour); } } } } return(new Path()); }