private static string _RandomStarName(int seed, StarData starData) { Random random = new Random(seed); int seed1 = random.Next(); double num1 = random.NextDouble(); double num2 = random.NextDouble(); if (starData.type == EStarType.GiantStar) { if (num2 < 0.400000005960464) { return(NameGen.RandomGiantStarNameFromRawNames(seed1)); } return(num2 < 0.699999988079071 ? NameGen.RandomGiantStarNameWithConstellationAlpha(seed1) : NameGen.RandomGiantStarNameWithFormat(seed1)); } if (starData.type == EStarType.NeutronStar) { return(NameGen.RandomNeutronStarNameWithFormat(seed1)); } if (starData.type == EStarType.BlackHole) { return(NameGen.RandomBlackHoleNameWithFormat(seed1)); } if (num1 < 0.600000023841858) { return(NameGen.RandomStarNameFromRawNames(seed1)); } return(num1 < 0.930000007152557 ? NameGen.RandomStarNameWithConstellationAlpha(seed1) : NameGen.RandomStarNameWithConstellationNumber(seed1)); }
public void Visit(Series target, Signature input) { var methodName = "ParseSeries"; var repeatedFunc = target.RepeatedToken; var repeatedInvocation = this.invokers[repeatedFunc]("i", "p", "s", "f"); // Invocation var delimFunc = target.DelimiterToken; var delimInvocation = this.invokers[delimFunc]("i", "p", "s", "f"); // Invocation var invocation = $"{methodName}(input, inputPosition, states, factory, (i, p, s, f) => {repeatedInvocation}, (i, p, s, f) => {delimInvocation})"; // Invocation var resultName = "result"; writer.VarAssign(resultName, invocation); writer.IfNullReturnNull(resultName); var nodeReference = $"{resultName}.Node"; var decl = new Decl(target.ReturnType, nodeReference); var returnExpression = GetReturnExpression(target.ReturnType, new[] { decl }, $"{resultName}.Advanced", "factory", target.InterfaceMethod); if (input.IsMemoized) { var memField = NameGen.MemoizedFieldName(input.Name); returnExpression = $"states[inputPosition].{memField} = {returnExpression}"; } writer.Return(returnExpression); }
// Use this for initialization void Start() { rrand = Random.Range(0, 100); food_hold = 0; last_hunger = Time.time; last_action = Time.time; last_sleep = Time.time + Random.Range(0, sleep_interval); last_mating = Time.time + Random.Range(mating_cooldown / 2, mating_cooldown); nextNode = mySquare; currentDestination = mySquare; wg = GameObject.FindGameObjectWithTag("world").GetComponent <WorldGen>(); wl = GameObject.FindGameObjectWithTag("world").GetComponent <WorldLogic>(); rf = gameObject.GetComponent <RabbitFinder>(); rm = gameObject.GetComponent <RabbitMover>(); ng = gameObject.GetComponent <NameGen>(); rm.SetPosition(wg.VertexToVector3(mySquare)); anim = gameObject.GetComponent <Animator>(); ng = gameObject.GetComponent <NameGen>(); //initiate rabbit stats myname = ng.getName(); hp = 20; maxhp = 20; hunger = 7; full = 10; str = Random.Range(1, 4); spd = Random.Range(1, 4); speed = 1 / (float)spd; if (!starting_rabbit) { profession = "Guard"; sex = Random.Range(0, 2); } }
private void modernButton2_Click(object sender, System.EventArgs e) { Log($"Test#1 Started @{DateTime.Now.ToString("h:mm:ss tt zz")}."); //MessageBox.Show(Application.StartupPath + @"\Web\loading.html"); //new IntroductionWindow().Show(); var rand = new Random(); float r = 0f; int rr = 0; var st = new Structure.ScoreTable(new Dictionary <string, ScoreModel>(), new InputDataIndicator()); var gw = new GridWindow("测试成绩数据"); NameGen ng = new NameGen(); for (int i = 1; i <= 100; i++) { r = rand.Next(0, 1500) / 10f; rr = rand.Next(1, 100); st.Add(ng.Rand2(), new ScoreModel(rr, rr, r, r, r, r, r, r, r, r, r, rr, rr, rr, rr, rr, rr, rr, rr, rr, rr, rr, rr, rr, rr, rr, rr, rr, rr)); } //st.Add(5001.ToString(), new ScoreModel(rr,rr,r, r, r, r, r, r, r, r, r, rr, rr, rr, rr, rr, rr, rr, rr, rr)); r = rand.Next(1, 100); //MessageBox.Show($"id:{r},zh:{st.Score[r.ToString()].Zh}", "Finished"); var ex = st.Export(); foreach (var i in ex) { gw.DisplayObjectBindingSource.Add(i); } gw.Show(); //st.CalcAverage(); }
public void placeEntities() { foreach (Transform current in enemyPositions) { enemies.Add(createEntity(NameGen.getName(), current, rounds * 50, false)); } if (allPlayers.Count == 0)//first time no players TODO: later we should have some char creation maybe { for (int i = 0; i < 4; i++) { allPlayers.Add(createEntity(NameGen.getName(), null, 255, true)); allPlayers[i].SetActive(false); } } for (int i = 0; i < playerPositions.Count; i++) { players.Add(allPlayers[i]); players[i].transform.SetParent(playerPositions[i]); players[i].transform.localPosition = new Vector3(0, 0, 0); players[i].SetActive(true); } }
public void Visit(Sequence target, Signature input) { var returnedResults = new List <Decl>(); int stepIndex = 0; var currentInputPosition = "inputPosition"; String currentAdvanced = null; foreach (var step in target.Steps) { stepIndex++; var func = step.Function; var type = func.ReturnType; var invoker = this.invokers[func]; var resultName = $"r{stepIndex}"; var nodeName = $"{resultName}.Node"; if (step.IsReturned) { returnedResults.Add(new Decl(type, nodeName)); } writer.VarAssign(resultName, invoker("input", currentInputPosition, "states", "factory")); // Invocation var thisAdvanced = $"{resultName}.Advanced"; switch (step.MatchAction) { case MatchAction.Consume: writer.IfNullReturnNull(resultName); currentInputPosition = $"{currentInputPosition} + {thisAdvanced}"; currentAdvanced = (currentAdvanced == null) ? (thisAdvanced) : ($"{currentAdvanced} + {thisAdvanced}"); break; case MatchAction.Fail: writer.IfNotNullReturnNull(resultName); break; case MatchAction.Rewind: writer.IfNullReturnNull(resultName); break; case MatchAction.Ignore: writer.IfNullReturnNull(resultName); currentInputPosition = $"{currentInputPosition} + {thisAdvanced}"; currentAdvanced = (currentAdvanced == null) ? (thisAdvanced) : ($"{currentAdvanced} + {thisAdvanced}"); break; } } var returnExpression = GetReturnExpression(target.ReturnType, returnedResults, currentAdvanced, "factory", target.InterfaceMethod); if (input.IsMemoized) { var memField = NameGen.MemoizedFieldName(input.Name); returnExpression = $"states[inputPosition].{memField} = {returnExpression}"; } writer.Return(returnExpression); }
public void CreateGame() { galaxy = GalaxyManager.instance; game = GameManager.instance; names = new NameGen(); GameManager.instance.setup = true; loadingPanel.SetActive(true); StartCoroutine("CreatingGame"); //Creates a new Game }
void Awake() { r = this; Before = SBefore.Split(','); After = SAfter.Split(','); Nouns = SNouns.Split(','); for (int i = 0; i < 100; i++) { Debug.Log(NameGen.Group()); } }
//Method is ran after Generator is finished public void DoneGen() { currentHealth = maxHealth; currentThirst = maxThirst; currentHunger = maxHunger; currentEnergy = maxEnergy; if (firstName == "" || firstName == null) { if (gameObject.GetComponent <NameGen>()) { NameGen nameGen = gameObject.GetComponent <NameGen>(); firstName = nameGen.FirstName(); } else { NameGen nameGen = gameObject.AddComponent <NameGen>(); firstName = nameGen.FirstName(); } } if (familyName == "" || familyName == null) { if (gameObject.GetComponent <NameGen>()) { NameGen nameGen = gameObject.GetComponent <NameGen>(); familyName = nameGen.LastName(); } else { NameGen nameGen = gameObject.AddComponent <NameGen>(); familyName = nameGen.LastName(); } } if (nickName.Length > 0) { displayName = firstName + " " + nickName; } else { displayName = firstName + " " + familyName; } if (Random.Range(1, 10) >= 3 && nickName.Length < 1) { NickNameGen nickNameGen = gameObject.AddComponent <NickNameGen>(); displayName = nickNameGen.NameGen(); } Debug.Log("Done generating " + displayName); }
public Mogwai(string key, Dictionary <double, Shift> shifts) { Key = key; Shifts = shifts; currentShift = shifts.Values.First(); LevelShifts.Add(currentShift.Height); // adding initial creation level up blockHeight = currentShift.Height; Pointer = currentShift.Height; // create appearance var hexValue = new HexValue(currentShift); Name = NameGen.GenerateName(hexValue); Body = new Body(hexValue); Coat = new Coat(hexValue); Stats = new Stats(hexValue); // create abilities int[] rollEvent = new int[] { 4, 6, 3 }; Gender = currentShift.MogwaiDice.Roll(2, -1); Strength = currentShift.MogwaiDice.Roll(rollEvent); Dexterity = currentShift.MogwaiDice.Roll(rollEvent); Constitution = currentShift.MogwaiDice.Roll(rollEvent); Inteligence = currentShift.MogwaiDice.Roll(rollEvent); Wisdom = currentShift.MogwaiDice.Roll(rollEvent); Charisma = currentShift.MogwaiDice.Roll(rollEvent); BaseSpeed = 30; NaturalArmor = 0; SizeType = SizeType.MEDIUM; BaseAttackBonus = new int[] { 0 }; // create experience Experience = new Experience(currentShift); // add simple rapier as weapon Equipment.PrimaryWeapon = Weapons.Rapier; // add simple rapier as weapon Equipment.Armor = Armors.StuddedLeather; HitPointDice = 8; CurrentHitPoints = MaxHitPoints; }
// Use this for initialization public override void Start() { try{ gameObject.name = NameGen.GenerateName("L4N2"); } catch { Debug.Log("NameGen failed"); gameObject.name = "NAMEGEN_ERROR"; } shipClass = GetComponent <ShipClass> (); Collections.Freighters.Add(this); Collections.Available.Add(this); agent = GetComponent <NavMeshAgent> (); controller = GameObject.FindGameObjectWithTag("Controller"); }
void Start() { if (nameGeneratorPrefab) { //this creates an instance of the generator and assigns it to the nameGenerator-variable GameObject nameGeneratorTemp = Instantiate(nameGeneratorPrefab) as GameObject; nameGenerator = nameGeneratorTemp.GetComponent <NameGen>(); CreateNewName(); } else { Debug.LogWarning("Assign the NameGenerator-Prefab to this script!", transform); } }
public void GenerateNameTest() { var hexValue = new HexValue( new Shift(0, 1530914381, "32ad9e02792599dfdb6a9d0bc0b924da23bd96b1b7eb4f0a68", 7234, "00000000090d6c6b058227bb61ca2915a84998703d4444cc2641e6a0da4ba37e", 2, "163d2e383c77765232be1d9ed5e06749a814de49b4c0a8aebf324c0e9e2fd1cf", 1.00m, 0.0001m)); Assert.Equal("Vihiryne", NameGen.GenerateName(hexValue)); }
public static ParsnipModel Go(ParsnipModel model) { var oldRules = model.Rules; foreach (var oldRule in oldRules) { var interfaceMethodName = NameGen.InterfaceMethodName(oldRule.RuleIdentifier); var vis = new Visitor(interfaceMethodName); (var newFunc, var newMethods) = oldRule.ParseFunction.ApplyVisitor(vis, oldRule.ReturnType); var newRule = oldRule.WithParseFunction(newFunc); model = model.ReplacingRule(oldRule, newRule); foreach (var method in newMethods) { model = model.AddingInterfaceMethod(method); } } return(model); }
private void BasicTargetWithInterfaceMethod(IParseFunction target, InterfaceMethod interfaceMethod, Signature signature) { var resultName = "r"; var nodeName = $"{resultName}.Node"; var invoker = this.invokers[target]; writer.VarAssign(resultName, invoker("input", "inputPosition", "states", "factory")); // Invocation writer.IfNullReturnNull(resultName); var decl = new Decl(target.ReturnType, nodeName); var returnExpression = GetReturnExpression(target.ReturnType, new[] { decl }, $"{resultName}.Advanced", "factory", interfaceMethod); if (signature.IsMemoized) { var memField = NameGen.MemoizedFieldName(signature.Name); returnExpression = $"states[inputPosition].{memField} = {returnExpression}"; } writer.Return(returnExpression); }
public void Visit(Selection target, Signature input) { int stepIndex = 0; foreach (var step in target.Steps) { stepIndex++; var func = step.Function; var invoker = this.invokers[func]; var resultName = $"r{stepIndex}"; writer.VarAssign(resultName, invoker("input", "inputPosition", "states", "factory")); // Invocation var factoryName = "factory"; var interfaceMethod = step.InterfaceMethod; var nodeReference = $"{resultName}.Node"; IReadOnlyList <Decl> nodes; if (func.ReturnType is TupleNodeType tupleNodeType) { nodes = tupleNodeType.Types.Select((i, j) => new Decl(i, $"{nodeReference}.Item{j + 1}")).ToList(); } else { nodes = new[] { new Decl(func.ReturnType, nodeReference) }; } var returnExpression = GetReturnExpression(target.ReturnType, nodes, $"{resultName}.Advanced", factoryName, interfaceMethod); if (input.IsMemoized) { var memField = NameGen.MemoizedFieldName(input.Name); returnExpression = $"states[inputPosition].{memField} = {returnExpression}"; } writer.LineOfCode($"if ({resultName} != null) return {returnExpression};"); } // No choices matched writer.Return("null"); }
public void Visit(Repetition target, Signature input) { String methodName; switch (target.Cardinality) { case Cardinality.Maybe: methodName = "ParseMaybe"; break; case Cardinality.Plus: methodName = "ParsePlus"; break; case Cardinality.Star: methodName = "ParseStar"; break; default: throw new InvalidOperationException(); } var innerFunc = target.InnerParseFunction; var innerInvocation = this.invokers[innerFunc]("i", "p", "s", "f"); // Invocation var invocation = $"{methodName}(input, inputPosition, states, factory, (i, p, s, f) => {innerInvocation})"; // Invocation var resultName = "result"; writer.VarAssign(resultName, invocation); writer.IfNullReturnNull(resultName); var nodeReference = $"{resultName}.Node"; var decl = new Decl(innerFunc.ReturnType, nodeReference); var returnExpression = GetReturnExpression(target.ReturnType, new[] { decl }, $"{resultName}.Advanced", "factory", target.InterfaceMethod); if (input.IsMemoized) { var memField = NameGen.MemoizedFieldName(input.Name); returnExpression = $"states[inputPosition].{memField} = {returnExpression}"; } writer.Return(returnExpression); }
public static string RandomStarName(int seed, StarData starData, GalaxyData galaxy) { Random random = new Random(seed); int num = 0; while (num++ < 256) { string str = NameGen._RandomStarName(random.Next(), starData); bool flag = false; for (int index = 0; index < galaxy.starCount; ++index) { if (galaxy.stars[index] != null && galaxy.stars[index].name.Equals(str)) { flag = true; break; } } if (!flag) { return(str); } } return("XStar"); }
// Use this for initialization void Start() { GetComponentInChildren <TextMesh>().text = NameGen.GetName(); }
/// <summary> /// Generates the chunk at xy chunk position. /// </summary> /// <returns>The chunk.</returns> /// <param name="xPos">X position.</param> /// <param name="yPos">Y position.</param> public void generateChunk(int xPos, int yPos) { if (loadedChunks == null) { Debug.LogWarning("lost chunks"); return; } // If the chunk is alreaady loaded on screen return if (loadedChunks.ContainsKey(xPos + " " + yPos)) { loadedChunks[xPos + " " + yPos] = null; return;// loadedChunks [xPos + " " + yPos]; } // Create chunk Chunk chunkMap = new Chunk(); GameObject chunkLoc = new GameObject("Chunk: " + xPos + " " + yPos); chunkLoc.transform.SetPositionAndRotation(new Vector3(xPos * Chunk.SIZE, 0, yPos * Chunk.SIZE), Quaternion.identity); for (int y = 0; y < Chunk.SIZE; y++) { for (int x = 0; x < Chunk.SIZE; x++) { // Check if this tile is edited already if (!addTerrain(x, y, xPos, yPos, chunkMap, terrainMap)) { Debug.Log("Terrain was not correctly added to tile " + x + " " + y); } //Generate resources addResource(x, y, xPos, yPos, chunkMap, resourceMap); } } loadedChunks[xPos + " " + yPos] = chunkMap; GameObject tempTile; GameObject tempResource; for (int y = 0; y < Chunk.SIZE; y++) { for (int x = 0; x < Chunk.SIZE; x++) { Position worldPos = new Position(xPos * Chunk.SIZE + x, yPos * Chunk.SIZE + y); string key = worldPos.xCoord + " " + worldPos.yCoord; tempTile = Instantiate(getObject(terrainMap[key]), new Vector3(worldPos.xCoord, 0, worldPos.yCoord), Quaternion.identity); if (terrainMap[key] == terrain.PLOT) { resourceMap[key] = resource.BUILDSIGN; } if (terrainMap[key] == terrain.CAMPSITE) { tempTile.name = "TownCenter"; } else { tempTile.transform.SetParent(chunkLoc.transform); } chunkMap.addTileAt(tempTile, x, y, 0); if (terrainMap[key] == terrain.CAMPSITE) { Instantiate(getObject(terrain.PLOT), new Vector3(worldPos.xCoord, 0, worldPos.yCoord), Quaternion.identity); } if (resourceMap.ContainsKey(key)) { if (resourceMap[key] == resource.NONE) { } else if (resourceMap[key] == resource.CAVE) { Instantiate(Cave, new Vector3(worldPos.xCoord, 0, worldPos.yCoord), Quaternion.identity); } else if (resourceMap[key] == resource.STONE) { int temp = Random.Range(1, 5); for (int i = 0; i < temp; i++) { int xtemp = Random.Range(-5, 5); int ytemp = Random.Range(-5, 5); if (Random.Range(0, 1000) < rareResourceRate) { tempResource = Instantiate(getResourceObject(resource.DIAMOND), new Vector3(worldPos.xCoord + ((float)xtemp / 10), 0, worldPos.yCoord + ((float)ytemp / 10)), getResourceObject(resourceMap[key]).transform.rotation); } else if (Random.Range(0, 100) < rareResourceRate) { tempResource = Instantiate(getResourceObject(resource.COAL), new Vector3(worldPos.xCoord + ((float)xtemp / 10), 0, worldPos.yCoord + ((float)ytemp / 10)), getResourceObject(resourceMap[key]).transform.rotation); } else { tempResource = Instantiate(getResourceObject(resourceMap[key]), new Vector3(worldPos.xCoord + ((float)xtemp / 10), 0, worldPos.yCoord + ((float)ytemp / 10)), getResourceObject(resourceMap[key]).transform.rotation); } tempResource.transform.SetParent(chunkLoc.transform); } } else if (resourceMap[key] == resource.IRON) { int temp = Random.Range(1, 3); for (int i = 0; i < temp; i++) { int xtemp = Random.Range(-5, 5); int ytemp = Random.Range(-5, 5); tempResource = Instantiate(getResourceObject(resourceMap[key]), new Vector3(worldPos.xCoord + ((float)xtemp / 10), 0, worldPos.yCoord + ((float)ytemp / 10)), getResourceObject(resourceMap[key]).transform.rotation); tempResource.transform.SetParent(chunkLoc.transform); } } else if (resourceMap[key] == resource.TREE) { int temp = Random.Range(1, 5); for (int i = 0; i < temp; i++) { int xtemp = Random.Range(-5, 5); int ytemp = Random.Range(-5, 5); tempResource = Instantiate(getResourceObject(resourceMap[key]), new Vector3(worldPos.xCoord + ((float)xtemp / 10), 0, worldPos.yCoord + ((float)ytemp / 10)), getResourceObject(resourceMap[key]).transform.rotation); tempResource.transform.SetParent(chunkLoc.transform); } } else if (resourceMap[key] == resource.BERRIES) { int temp = Random.Range(1, 5); for (int i = 0; i < temp; i++) { int xtemp = Random.Range(-5, 5); int ytemp = Random.Range(-5, 5); tempResource = Instantiate(getResourceObject(resourceMap[key]), new Vector3(worldPos.xCoord + ((float)xtemp / 10), 0, worldPos.yCoord + ((float)ytemp / 10)), getResourceObject(resourceMap[key]).transform.rotation); tempResource.transform.SetParent(chunkLoc.transform); } } else { tempResource = Instantiate(getResourceObject(resourceMap[key]), new Vector3(worldPos.xCoord, 0, worldPos.yCoord), getResourceObject(resourceMap[key]).transform.rotation); if (resourceMap[key] == resource.NPC) { tempResource.GetComponent <QuestNPC>().addGoal(tempResource.GetComponent <Skills>().getIntRank()); tempResource.name = NameGen.create(); tempResource.GetComponentInChildren <TextMesh>().text = tempResource.name; } else { tempResource.transform.SetParent(chunkLoc.transform); } chunkMap.addTileAt(tempTile, x, y, 1); } } } } }
public Mogwai(string key, Dictionary <long, Shift> shifts) { Key = key; Shifts = new ConcurrentDictionary <long, Shift>(shifts); _currentShift = shifts.Values.First(); LevelShifts.Add(_currentShift.Height); // adding initial creation level up Pointer = _currentShift.Height; // create appearance var hexValue = new HexValue(_currentShift); Name = NameGen.GenerateName(hexValue); Body = new Body(hexValue); Coat = new Coat(hexValue); Stats = new Stats(hexValue); // create abilities var rollEvent = new[] { 4, 6, 3 }; Gender = _currentShift.MogwaiDice.Roll(2, -1); BaseStrength = _currentShift.MogwaiDice.Roll(rollEvent); BaseDexterity = _currentShift.MogwaiDice.Roll(rollEvent); BaseConstitution = _currentShift.MogwaiDice.Roll(rollEvent); BaseIntelligence = _currentShift.MogwaiDice.Roll(rollEvent); BaseWisdom = _currentShift.MogwaiDice.Roll(rollEvent); BaseCharisma = _currentShift.MogwaiDice.Roll(rollEvent); BaseSpeed = 30; NaturalArmor = 0; SizeType = SizeType.Medium; BaseAttackBonus = new[] { 0 }; Faction = Faction.Hero; // create experience Experience = new Experience(_currentShift); // create slot types Equipment.CreateEquipmentSlots(new[] { SlotType.Head, SlotType.Shoulders, SlotType.Neck, SlotType.Chest, SlotType.Armor, SlotType.Belt, SlotType.Wrists, SlotType.Hands, SlotType.Ring, SlotType.Ring, SlotType.Feet }); // add weapon slot Equipment.WeaponSlots.Add(new WeaponSlot()); // add simple weapon var baseWeapon = Weapons.Instance.ByName("Warhammer"); AddToInventory(baseWeapon); EquipWeapon(baseWeapon); // add simple studded leather as armor //Equipment.Armor = Armors.StuddedLeather; var baseArmor = Armors.Instance.ByName("Studded Leather"); AddToInventory(baseArmor); EquipItem(SlotType.Armor, baseArmor); HitPointDice = 6; CurrentHitPoints = MaxHitPoints; EnvironmentTypes = new[] { EnvironmentType.Any }; // create home town HomeTown = new HomeTown(_currentShift); }
public StarData CreateStar( GalaxyData galaxy, VectorLF3 pos, int id, int seed, EStarType needtype, ESpectrType needSpectr = ESpectrType.X) { StarData starData = new StarData() { galaxy = galaxy, index = id - 1 }; starData.level = galaxy.starCount <= 1 ? 0.0f : (float)starData.index / (float)(galaxy.starCount - 1); starData.id = id; starData.seed = seed; Random random1 = new Random(seed); int seed1 = random1.Next(); int Seed = random1.Next(); starData.position = pos; float num1 = (float)pos.magnitude / 32f; if ((double)num1 > 1.0) { num1 = Mathf.Log(Mathf.Log(Mathf.Log(Mathf.Log(Mathf.Log(num1) + 1f) + 1f) + 1f) + 1f) + 1f; } starData.resourceCoef = Mathf.Pow(7f, num1) * 0.6f; Random random2 = new Random(Seed); double r1 = random2.NextDouble(); double r2 = random2.NextDouble(); double num2 = random2.NextDouble(); double rn = random2.NextDouble(); double rt = random2.NextDouble(); double num3 = (random2.NextDouble() - 0.5) * 0.2; double num4 = random2.NextDouble() * 0.2 + 0.9; double y = random2.NextDouble() * 0.4 - 0.2; double num5 = Math.Pow(2.0, y); float num6 = Mathf.Lerp(-0.98f, 0.88f, starData.level); float averageValue = (double)num6 >= 0.0 ? num6 + 0.65f : num6 - 0.65f; float standardDeviation = 0.33f; if (needtype == EStarType.GiantStar) { averageValue = y <= -0.08 ? 1.6f : -1.5f; standardDeviation = 0.3f; } float num7 = this.RandNormal(averageValue, standardDeviation, r1, r2); switch (needSpectr) { case ESpectrType.M: num7 = -3f; break; case ESpectrType.O: num7 = 3f; break; } float p1 = (float)((double)Mathf.Clamp((double)num7 <= 0.0 ? num7 * 1f : num7 * 2f, -2.4f, 4.65f) + num3 + 1.0); switch (needtype) { case EStarType.WhiteDwarf: starData.mass = (float)(1.0 + r2 * 5.0); break; case EStarType.NeutronStar: starData.mass = (float)(7.0 + r1 * 11.0); break; case EStarType.BlackHole: starData.mass = (float)(18.0 + r1 * r2 * 30.0); break; default: starData.mass = Mathf.Pow(2f, p1); break; } double d = 5.0; if ((double)starData.mass < 2.0) { d = 2.0 + 0.4 * (1.0 - (double)starData.mass); } starData.lifetime = (float)(10000.0 * Math.Pow(0.1, Math.Log10((double)starData.mass * 0.5) / Math.Log10(d) + 1.0) * num4); switch (needtype) { case EStarType.GiantStar: starData.lifetime = (float)(10000.0 * Math.Pow(0.1, Math.Log10((double)starData.mass * 0.58) / Math.Log10(d) + 1.0) * num4); starData.age = (float)(num2 * 0.0399999991059303 + 0.959999978542328); break; case EStarType.WhiteDwarf: case EStarType.NeutronStar: case EStarType.BlackHole: starData.age = (float)(num2 * 0.400000005960464 + 1.0); if (needtype == EStarType.WhiteDwarf) { starData.lifetime += 10000f; break; } if (needtype == EStarType.NeutronStar) { starData.lifetime += 1000f; break; } break; default: starData.age = (double)starData.mass >= 0.5 ? ((double)starData.mass >= 0.8 ? (float)(num2 * 0.699999988079071 + 0.200000002980232) : (float)(num2 * 0.400000005960464 + 0.100000001490116)) : (float)(num2 * 0.119999997317791 + 0.0199999995529652); break; } float num8 = starData.lifetime * starData.age; if ((double)num8 > 5000.0) { num8 = (float)(((double)Mathf.Log(num8 / 5000f) + 1.0) * 5000.0); } if ((double)num8 > 8000.0) { num8 = (Mathf.Log(Mathf.Log(Mathf.Log(num8 / 8000f) + 1f) + 1f) + 1f) * 8000f; } starData.lifetime = num8 / starData.age; float f = (float)(1.0 - (double)Mathf.Pow(Mathf.Clamp01(starData.age), 20f) * 0.5) * starData.mass; starData.temperature = (float)(Math.Pow((double)f, 0.56 + 0.14 / (Math.Log10((double)f + 4.0) / Math.Log10(5.0))) * 4450.0 + 1300.0); double num9 = Math.Log10(((double)starData.temperature - 1300.0) / 4500.0) / Math.Log10(2.6) - 0.5; if (num9 < 0.0) { num9 *= 4.0; } if (num9 > 2.0) { num9 = 2.0; } else if (num9 < -4.0) { num9 = -4.0; } starData.spectr = (ESpectrType)Mathf.RoundToInt((float)num9 + 4f); starData.color = Mathf.Clamp01((float)((num9 + 3.5) * 0.200000002980232)); starData.classFactor = (float)num9; starData.luminosity = Mathf.Pow(f, 0.7f); starData.radius = (float)(Math.Pow((double)starData.mass, 0.4) * num5); starData.acdiskRadius = 0.0f; float p2 = (float)num9 + 2f; starData.habitableRadius = Mathf.Pow(1.7f, p2) + 0.25f * Mathf.Min(1f, starData.orbitScaler); starData.lightBalanceRadius = Mathf.Pow(1.7f, p2); starData.orbitScaler = Mathf.Pow(1.35f, p2); if ((double)starData.orbitScaler < 1.0) { starData.orbitScaler = Mathf.Lerp(starData.orbitScaler, 1f, 0.6f); } this.SetStarAge(starData, starData.age, rn, rt); starData.dysonRadius = starData.orbitScaler * 0.28f; if ((double)starData.dysonRadius * 40000.0 < (double)starData.physicsRadius * 1.5) { starData.dysonRadius = (float)((double)starData.physicsRadius * 1.5 / 40000.0); } starData.uPosition = starData.position * 2400000.0; starData.name = NameGen.RandomStarName(seed1, starData, galaxy); starData.overrideName = string.Empty; return(starData); }
private void PopulateCredits(Text text, bool startingText = false) { const int linesPerScreen = 15; var sb = new StringBuilder(); if (startingText) { sb.AppendLine("Producer"); sb.AppendLine(BigNameSize + "Blair Knickerbocker" + EndSize); sb.AppendLine(); sb.AppendLine("Directed by"); sb.AppendLine(BigNameSize + "James Walker" + EndSize); sb.AppendLine(); sb.AppendLine("Sound Direction by"); sb.AppendLine(BigNameSize + "Katie Tarrant" + EndSize); sb.AppendLine(); sb.AppendLine("Art Direction by"); sb.AppendLine(BigNameSize + "Rachael Jones" + EndSize); sb.AppendLine(); } else { switch (Random.Range(0, 10)) { case 0: case 1: case 2: // Job Title // Name1 Name2 sb.AppendLine(BigNameSize + JobTitleGen.GetJobTitlePlural() + EndSize); sb.AppendLine(); var names2 = new KeyValuePair <string, string> [linesPerScreen - 2]; for (int i = 0; i < names2.Length; i++) { names2[i] = new KeyValuePair <string, string>(NameGen.GetName(), NameGen.GetName()); } var maxNameWidth = names2.SelectMany(n => new[] { n.Key, n.Value }).OrderByDescending(n => n.Length).First().Length; var format = string.Format("{{0,-{0}}} {{1,{0}}}", maxNameWidth); for (int i = 0; i < names2.Length; i++) { sb.AppendLine(string.Format(format, names2[i].Key, names2[i].Value)); } break; case 3: case 4: case 5: // Job Title // Name1 Name2 // Job Title // Name1 Name2 const int linesPerBlock = 4; for (int j = 0; j < 2; j++) { sb.AppendLine(BigNameSize + JobTitleGen.GetJobTitlePlural() + EndSize); sb.AppendLine(); var names3 = new KeyValuePair <string, string> [linesPerBlock]; for (int i = 0; i < linesPerBlock; i++) { names3[i] = new KeyValuePair <string, string>(NameGen.GetName(), NameGen.GetName()); } maxNameWidth = names3.SelectMany(n => new[] { n.Key, n.Value }).OrderByDescending(n => n.Length).First().Length; format = string.Format("{{0,-{0}}} {{1,{0}}}", maxNameWidth); for (int i = 0; i < names3.Length; i++) { sb.AppendLine(string.Format(format, names3[i].Key, names3[i].Value)); } sb.AppendLine(); } break; case 6: case 7: case 8: switch (Random.Range(0, 2)) { case 0: sb.AppendLine(LargeSize + "Special Thanks to" + EndSize); break; case 1: sb.AppendLine(LargeSize + "Extras" + EndSize); break; } sb.AppendLine(); names2 = new KeyValuePair <string, string> [linesPerScreen - 2]; for (int i = 0; i < names2.Length; i++) { names2[i] = new KeyValuePair <string, string>(JobTitleGen.GetJobTitle(), NameGen.GetName()); } maxNameWidth = names2.SelectMany(n => new[] { n.Key, n.Value }).OrderByDescending(n => n.Length).First().Length; format = string.Format("<b>{{0,-{0}}}</b> {{1,{0}}}", maxNameWidth); for (int i = 0; i < names2.Length; i++) { sb.AppendLine(string.Format(format, names2[i].Key, names2[i].Value)); } break; case 9: // Production babies! sb.AppendLine(LargeSize + "Production Babies!" + EndSize); sb.AppendLine(); names2 = new KeyValuePair <string, string> [linesPerScreen - 2]; for (int i = 0; i < names2.Length; i++) { names2[i] = new KeyValuePair <string, string>(NameGen.GetName(), NameGen.GetName()); } maxNameWidth = names2.SelectMany(n => new[] { n.Key, n.Value }).OrderByDescending(n => n.Length).First().Length; format = string.Format("{{0,-{0}}} {{1,{0}}}", maxNameWidth); for (int i = 0; i < names2.Length; i++) { sb.AppendLine(string.Format(format, names2[i].Key, names2[i].Value)); } break; case 10: break; } } text.text = sb.ToString(); }
public static String GetParseResultTypeString(this INodeType returnType) => $"ParseResult<{NameGen.TypeString(returnType)}>";
// Use this for initialization void Start() { NodeID = NameGen.GenerateName("L3N2L1"); }
private static string[] InitialSort(string inputFile, string tempDir, Options opt) { List<string> tempFiles = new List<string>(); var sw = new System.Diagnostics.Stopwatch(); sw.Start(); //read a chunk, sort it, then write it to file using (StreamReader reader = new StreamReader(inputFile)) { using (ManualResetEvent mre = new ManualResetEvent(true)) { NameGen nameGen = new NameGen(tempDir); string line; int lineNo = 0; int maxSortSize = opt.MaxSortSize; SortParam[] parameters = new SortParam[2]; parameters[0] = new SortParam(maxSortSize, mre, 0); parameters[1] = new SortParam(maxSortSize, mre, 1); int currentParam = 0; int[] buffer = parameters[currentParam].buffer; int j = 0; while ((line = reader.ReadLine()) != null) { lineNo++; int data; //if (Int32.TryParse(line, out data)) //slow if (StringToInt(line, out data)) { buffer[j++] = data; if (j >= maxSortSize) { string name = nameGen.NewName(); tempFiles.Add(name); parameters[currentParam].Reset(j, name); SortOnThread(parameters[currentParam]); //swap currentParam = (currentParam + 1) % 2; buffer = parameters[currentParam].buffer; j = 0; } } else Warn("Skipping line " + lineNo.ToString()); } if (j > 0) { string name = nameGen.NewName(); tempFiles.Add(name); parameters[currentParam].Reset(j, name); SortOnThread(parameters[currentParam]); } mre.WaitOne(); parameters[0].mre = null; parameters[1].mre = null; } reader.Close(); } sw.Stop(); Console.WriteLine("Time to sort intermediate files: {0}", sw.Elapsed.ToString()); return tempFiles.ToArray(); }
// Use this for initialization void Start() { rrand = Random.Range(0, 100); food_hold = 0; last_hunger = Time.time; last_action = Time.time; last_sleep = Time.time + Random.Range(0, sleep_interval); last_mating = Time.time + Random.Range(mating_cooldown/2, mating_cooldown); nextNode = mySquare; currentDestination = mySquare; wg = GameObject.FindGameObjectWithTag("world").GetComponent<WorldGen>(); wl = GameObject.FindGameObjectWithTag("world").GetComponent<WorldLogic>(); rf = gameObject.GetComponent<RabbitFinder>(); rm = gameObject.GetComponent<RabbitMover>(); ng = gameObject.GetComponent<NameGen>(); rm.SetPosition(wg.VertexToVector3(mySquare)); anim = gameObject.GetComponent<Animator>(); ng = gameObject.GetComponent<NameGen>(); //initiate rabbit stats myname = ng.getName(); hp = 20; maxhp = 20; hunger = 7; full = 10; str = Random.Range(1,4); spd = Random.Range(1,4); speed = 1 / (float)spd; if(!starting_rabbit){ profession = "Guard"; sex = Random.Range(0,2); } }
public static string Next() { return(JobTitleGen.GetJobTitle() + ": " + NameGen.GetName()); }
public static char[] buildCFirstPair() { return(new char[2] { NameGen.getRandConsonat(), NameGen.getRandVowel() }); }
public StarData CreateBirthStar(GalaxyData galaxy, int seed) { StarData starData = new StarData(); starData.galaxy = galaxy; starData.index = 0; starData.level = 0.0f; starData.id = 1; starData.seed = seed; starData.resourceCoef = 0.6f; Random random1 = new Random(seed); int seed1 = random1.Next(); int Seed = random1.Next(); starData.name = NameGen.RandomName(seed1); starData.overrideName = string.Empty; starData.position = VectorLF3.zero; Random random2 = new Random(Seed); double r1 = random2.NextDouble(); double r2 = random2.NextDouble(); double num1 = random2.NextDouble(); double rn = random2.NextDouble(); double rt = random2.NextDouble(); double num2 = random2.NextDouble() * 0.2 + 0.9; double num3 = Math.Pow(2.0, random2.NextDouble() * 0.4 - 0.2); float p1 = Mathf.Clamp(this.RandNormal(0.0f, 0.08f, r1, r2), -0.2f, 0.2f); starData.mass = Mathf.Pow(2f, p1); if ((double)this.specifyBirthStarMass > 0.100000001490116) { starData.mass = this.specifyBirthStarMass; } if ((double)this.specifyBirthStarAge > 9.99999974737875E-06) { starData.age = this.specifyBirthStarAge; } double d = 2.0 + 0.4 * (1.0 - (double)starData.mass); starData.lifetime = (float)(10000.0 * Math.Pow(0.1, Math.Log10((double)starData.mass * 0.5) / Math.Log10(d) + 1.0) * num2); starData.age = (float)(num1 * 0.4 + 0.3); if ((double)this.specifyBirthStarAge > 9.99999974737875E-06) { starData.age = this.specifyBirthStarAge; } float f = (float)(1.0 - (double)Mathf.Pow(Mathf.Clamp01(starData.age), 20f) * 0.5) * starData.mass; starData.temperature = (float)(Math.Pow((double)f, 0.56 + 0.14 / (Math.Log10((double)f + 4.0) / Math.Log10(5.0))) * 4450.0 + 1300.0); double num4 = Math.Log10(((double)starData.temperature - 1300.0) / 4500.0) / Math.Log10(2.6) - 0.5; if (num4 < 0.0) { num4 *= 4.0; } if (num4 > 2.0) { num4 = 2.0; } else if (num4 < -4.0) { num4 = -4.0; } starData.spectr = (ESpectrType)Mathf.RoundToInt((float)num4 + 4f); starData.color = Mathf.Clamp01((float)((num4 + 3.5) * 0.200000002980232)); starData.classFactor = (float)num4; starData.luminosity = Mathf.Pow(f, 0.7f); starData.radius = (float)(Math.Pow((double)starData.mass, 0.4) * num3); starData.acdiskRadius = 0.0f; float p2 = (float)num4 + 2f; starData.habitableRadius = Mathf.Pow(1.7f, p2) + 0.2f * Mathf.Min(1f, starData.orbitScaler); starData.lightBalanceRadius = Mathf.Pow(1.7f, p2); starData.orbitScaler = Mathf.Pow(1.35f, p2); if ((double)starData.orbitScaler < 1.0) { starData.orbitScaler = Mathf.Lerp(starData.orbitScaler, 1f, 0.6f); } this.SetStarAge(starData, starData.age, rn, rt); starData.dysonRadius = starData.orbitScaler * 0.28f; if ((double)starData.dysonRadius * 40000.0 < (double)starData.physicsRadius * 1.5) { starData.dysonRadius = (float)((double)starData.physicsRadius * 1.5 / 40000.0); } starData.uPosition = VectorLF3.zero; starData.name = NameGen.RandomStarName(seed1, starData, galaxy); starData.overrideName = string.Empty; return(starData); }