public void update(Vector3 player, Algorithm2 algorithm) { init(); //Debug.Log(getDiagonal()); //Debug.Log(getCenterDistance(player)); // Split the chunk if the distance to the center is less than half of our diagonal if (getDiagonal() / 2f > getCenterDistance(player) && children.Count == 0) { split(algorithm); meshRenderer.enabled = false; } else if (getDiagonal() / 2f < getCenterDistance(player)) { merge(); meshRenderer.enabled = true; } // Update children as well foreach (Chunk2 c in children) { c.update(player, algorithm); } }
/// <summary> /// Create a new set of teams /// </summary> /// <param name="teamCount">The number of teams to generate</param> public async Task CreateNewRound(int teamCount, CancellationToken cancel) { var teams = new List <Team>(); if (Settings.Algorithm2) { var algo2 = new Algorithm2() { LoggingOn = Settings.LoggingOn, LoggingPath = _storage.LoggingPath }; teams = algo2.Generate(PlayerProvider, teamCount, Rounds.ToList()); } else { var numTeamGens = Settings.NumberOfGenerations; var teamCreator = new RoundCreator(); var winnersPenalty = new TooManyWinnersPenalty(PlayerProvider); var penalties = new IPenalty[] { PlayerPairings, winnersPenalty }; teams = await teamCreator.CreateApproximatelyOptimalTeams(penalties, PlayerProvider, numTeamGens, teamCount, cancel); } var filename = _storage.GetNextHatRoundPath(); var round = new HatRound(teams, filename); round.SaveToFile(); AddRound(round); }
public static void createQuad(float i, float j, float quadSize, Algorithm2 algorithm, TriangleList meshData, Transform transform) { // North Vertex a = new Vertex(i, 0, j); Vertex b = new Vertex(i, 0, j + quadSize); Vertex c = new Vertex(i + quadSize, 0, j + quadSize); Vertex d = new Vertex(i + quadSize, 0, j); // Apply terrain features based on the algorithm /*a.position = transform.TransformPoint(a.position); * b.position = transform.TransformPoint(b.position); * c.position = transform.TransformPoint(c.position); * d.position = transform.TransformPoint(d.position); * a.position = transform.InverseTransformPoint(a.position.normalized * algorithm.getHeight(a.position)); * b.position = transform.InverseTransformPoint(b.position.normalized * algorithm.getHeight(b.position)); * c.position = transform.InverseTransformPoint(c.position.normalized * algorithm.getHeight(c.position)); * d.position = transform.InverseTransformPoint(d.position.normalized * algorithm.getHeight(d.position));*/ // Texture coordinates a.uv = calcUV(a.position); b.uv = calcUV(b.position); c.uv = calcUV(c.position); d.uv = calcUV(d.position); // Add to geometry meshData.Add(new Triangle(a, b, c)); meshData.Add(new Triangle(c, d, a)); }
void split(Algorithm2 algorithm) { Vector3 center = getCenter(); // Create 4 children children.Add(createChild(startPoint, getCenter(), algorithm)); children.Add(createChild(new Vector3(startPoint.x, 0, center.z), new Vector3(center.x, 0, endPoint.z), algorithm)); children.Add(createChild(center, endPoint, algorithm)); children.Add(createChild(new Vector3(center.x, 0, startPoint.z), new Vector3(endPoint.x, 0, center.z), algorithm)); }
Chunk2 createChild(Vector3 start, Vector3 end, Algorithm2 algorithm) { Chunk2 child = (Instantiate(chunkPrefab, start, Quaternion.identity) as GameObject).GetComponent <Chunk2>(); child.transform.parent = transform; child.name = "Chunk " + start.x + "_" + start.z; child.startPoint = start; child.endPoint = end; child.createGeometry(meshRenderer.sharedMaterial, algorithm); return(child); }
// protected void Page_Load(object sender, EventArgs e) { Algorithm2.setStackData(); Algorithm2.setTStackIData(); Algorithm2.setTStackHData(); Algorithm2.setLoopSizeData(); Algorithm2.setTriloopData(); Algorithm2.setTetraloopData(); Algorithm2.setInterior_1x2_Data(); Algorithm2.setInterior2x2Data(); }
public static void Algorithm_Two(string inputsequence, bool direction, bool sbol, string path) { inputsequence = inputsequence.ToUpper(); Algorithm1.input(inputsequence, 1, 4, true, true, true, 1000, 1000, direction, sbol, path, ""); terminatorSequence = Algorithm1.terminatorSequence; Warn = Algorithm1.Warn; if (Warn == false) { Algorithm2.Score(Algorithm1.aTail[0], Algorithm1.stemloop[0], Algorithm1.spacerSequence[0], Algorithm1.tTail[0]); Score = Algorithm2.dscore.ToString("f1"); efficiency = Algorithm2.terminatorefficiency.ToString("f0"); structure = Algorithm2.Full_Structure; } else { Warning = "There is something wrong with your sequence!"; } }
public void createGeometry(Material material, Algorithm2 algorithm) { init(); // Generate the quads float quadSize = (new Vector3(startPoint.x, 0, endPoint.z) - startPoint).magnitude / (float)quads; for (int i = 0; i < quads; i++) { for (int j = 0; j < quads; j++) { Chunk2.createQuad((float)i * quadSize, (float)j * quadSize, quadSize, algorithm, meshData, transform); } } // Pass the data to the mesh meshRenderer.sharedMaterial = material; meshData.GenerateData(meshFilter.sharedMesh); // Recalculate bounds and normals meshFilter.sharedMesh.RecalculateBounds(); NormalSolver.RecalculateNormals(meshFilter.sharedMesh, 60); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value == null) { return(Binding.DoNothing); } var values = value.ToString().Split(',').Select(v => int.Parse(v.Trim())).ToArray(); var controls = new UserControl[values.Length]; for (var i = 0; i < values.Length; i++) { switch (values[i]) { case 0: controls[i] = new Algorithm0 { Width = 180, Height = 70 }; break; case 1: controls[i] = new Algorithm1 { Width = 180, Height = 70 }; break; case 2: controls[i] = new Algorithm2 { Width = 180, Height = 70 }; break; case 3: controls[i] = new Algorithm3 { Width = 180, Height = 70 }; break; case 4: controls[i] = new Algorithm4 { Width = 180, Height = 70 }; break; case 5: controls[i] = new Algorithm5 { Width = 180, Height = 70 }; break; case 6: controls[i] = new Algorithm6 { Width = 180, Height = 70 }; break; case 7: controls[i] = new Algorithm7 { Width = 180, Height = 70 }; break; default: throw new ArgumentOutOfRangeException(nameof(value)); } controls[i].Tag = i; } return(controls); }
private string GetAlgoLabel() { return(Algorithm1.GetDescription() + " + " + Algorithm2.GetDescription()); }