public static QuestStep MakeDeliveryQuest(Entity provider, WorldInstance overworldRef) { QuestAction action = QuestAction.Deliver; int random = RNG.Roll(0, ItemHandler.GetFlatItemList().Count - 1); ItemInstance deliveryItem = new ItemInstance(ItemHandler.GetFlatItemList()[random], new Vector2Int(-1, -1), true); if (provider.Backpack.Count > 0) { int result = RNG.Roll(0, provider.Backpack.Count - 1); deliveryItem = provider.Backpack[result]; } Entity endPoint = overworldRef.GetRandomSentientWorldWide(); QuestStep step = new QuestStep(action, new List <ItemInstance>() { deliveryItem }, new List <JoyObject>() { endPoint }, new List <World.WorldInstance>()); return(step); }
public Queue <Vector2Int> FindPath(Vector2Int from, Vector2Int to, WorldInstance worldRef) { WorldInstance world = worldRef; List <Vector2Int> walls = new List <Vector2Int>(); lock (world.Objects) { List <JoyObject> tempList = world.Objects.ToList(); Dictionary <Vector2Int, JoyObject> wallsDictionary = tempList.Where(x => x.IsWall).ToDictionary(x => x.WorldPosition, x => x); walls.AddRange(wallsDictionary.Keys); } AStar pathfinder = new AStar(); AStarNode.sizes = new Vector2Int(world.Tiles.GetLength(0), world.Tiles.GetLength(1)); AStarNode.walls = walls; AStarNode goalNode = new AStarNode2D(null, null, 0, to.x, to.y); AStarNode startNode = new AStarNode2D(null, goalNode, 0, from.x, from.y); pathfinder.FindPath(startNode, goalNode); Queue <Vector2Int> path = new Queue <Vector2Int>(); for (int i = 0; i < pathfinder.solution.Count; i++) { AStarNode2D node = (AStarNode2D)pathfinder.solution[i]; path.Enqueue(new Vector2Int(node.x, node.y)); } return(path); }
public static void Serialise(WorldInstance world) { try { if (!Directory.Exists(Directory.GetCurrentDirectory() + "/save/" + world.Name)) { Directory.CreateDirectory(Directory.GetCurrentDirectory() + "/save/" + world.Name); } } catch (Exception e) { Console.WriteLine("Cannot open directory. Quitting."); Console.WriteLine(e.Message); Environment.Exit(-1); } try { string worldString = JsonUtility.ToJson(world); byte[] worldBytes = Encoding.ASCII.GetBytes(worldString); StreamWriter writer = new StreamWriter(Directory.GetCurrentDirectory() + "/save/" + world.Name + "/sav.dat", false); writer.WriteLine(worldString); writer.Close(); } catch (Exception e) { Console.WriteLine("Cannot serialise and/or write world to file. Quitting."); Console.WriteLine(e.Message); Environment.Exit(-1); } }
public static QuestStep MakeExploreQuest(Entity provider, WorldInstance overworldRef) { QuestAction action = QuestAction.Explore; List <WorldInstance> worlds = overworldRef.GetWorlds(overworldRef); WorldInstance target = overworldRef; WorldInstance currentWorld = provider.MyWorld; while (true) { target = worlds[RNG.Roll(0, worlds.Count - 1)]; if (target.GUID != currentWorld.GUID && target.GUID != overworldRef.GUID) { break; } } QuestStep step = new QuestStep(action, new List <ItemInstance>(), new List <JoyObject>(), new List <WorldInstance>() { target }); return(step); }
public static PhysicsResult IsCollision(Vector2Int from, Vector2Int to, WorldInstance worldRef) { Entity tempEntity = worldRef.GetEntity(to); if (tempEntity != null && from != to) { if (tempEntity.WorldPosition != from) { return(PhysicsResult.EntityCollision); } } if (worldRef.Walls.ContainsKey(to)) { return(PhysicsResult.WallCollision); } JoyObject obj = worldRef.GetObject(to); if (obj != null) { return(PhysicsResult.ObjectCollision); } else { return(PhysicsResult.None); } }
private void CreateRendererStates() { _logRendererState = new LogRendererState { Visible = _logConfiguration.Visible, MaximumVisibleLogLines = _logConfiguration.MaximumVisibleLogLines, MinimumWindowWidth = _logConfiguration.MinimumWindowWidth, LogEntryLifetime = _logConfiguration.LogEntryLifetime, ShowTimestamps = _logConfiguration.ShowTimestamps, ShowRaisingEvents = _logConfiguration.ShowRaisingEvents }; _worldTimeRendererState = new WorldTimeRendererState { Visible = _worldTimeConfiguration.Visible }; var worldTime = new WorldTime(_worldTimeRendererState); var worldObserver = new WorldObserver(worldTime, _logRendererState); _worldInstance = new WorldInstance(_world, _player, worldTime, worldObserver, _multimediaPlayer); _boardRendererState = new BoardRendererState(_worldInstance.Player); _fpsRendererState = new FpsRendererState { Visible = _fpsConfiguration.Visible }; }
public IWorldInstance Deserialise(string worldName) { string directory = Directory.GetCurrentDirectory() + "/save/" + worldName; string json = File.ReadAllText(directory + "/relationships.dat"); Dictionary tempDict = this.GetDictionary(json); GlobalConstants.GameManager.RelationshipHandler.Load(tempDict); json = File.ReadAllText(directory + "/entities.dat"); tempDict = this.GetDictionary(json); GlobalConstants.GameManager.EntityHandler.Load(tempDict); json = File.ReadAllText(directory + "/items.dat"); tempDict = this.GetDictionary(json); GlobalConstants.GameManager.ItemHandler.Load(tempDict); json = File.ReadAllText(directory + "/quests.dat"); tempDict = this.GetDictionary(json); GlobalConstants.GameManager.QuestTracker.Load(tempDict); json = File.ReadAllText(directory + "/world.dat"); tempDict = this.GetDictionary(json); IWorldInstance overworld = new WorldInstance(); overworld.Load(tempDict); return(overworld); }
/// <summary> /// Places items in the dungeon /// </summary> /// <param name="worldRef">The world in which to place the items</param> /// <param name="prosperity">The prosperity of the world, the lower the better</param> /// <returns>The items placed</returns> public static List <ItemInstance> PlaceItems(WorldInstance worldRef, int prosperity = 50) { List <ItemInstance> placedItems = new List <ItemInstance>(); int dungeonArea = worldRef.Tiles.GetLength(0) * worldRef.Tiles.GetLength(1); int itemsToPlace = dungeonArea / prosperity; List <Vector2Int> unavailablePoints = new List <Vector2Int>(); foreach (JoyObject wall in worldRef.Walls.Values) { unavailablePoints.Add(wall.WorldPosition); } for (int i = 0; i < itemsToPlace; i++) { Vector2Int point = new Vector2Int(RNG.Roll(1, worldRef.Tiles.GetLength(0) - 1), RNG.Roll(1, worldRef.Tiles.GetLength(1) - 1)); while (unavailablePoints.Contains(point)) { point = new Vector2Int(RNG.Roll(1, worldRef.Tiles.GetLength(0) - 1), RNG.Roll(1, worldRef.Tiles.GetLength(1) - 1)); } ItemInstance item = ItemProvider.RandomItem(false); item.Move(point); placedItems.Add(item); } return(placedItems); }
public MessageInputHandler(WorldInstance worldInstance, MessageRendererState messageRendererState, TimeSpan totalTime, Action<IXnaGameTime> messageClosingDelegate) { worldInstance.ThrowIfNull("worldInstance"); messageRendererState.ThrowIfNull("messageRendererState"); messageClosingDelegate.ThrowIfNull("messageClosingDelegate"); _worldInstance = worldInstance; _messageRendererState = messageRendererState; _messageClosingDelegate = messageClosingDelegate; _answerKeyboardStateHelper = new KeyboardStateHelper( KeyDown, null, null, TextAdventure.Xna.Constants.MessageRenderer.Input.AcceptKey, TextAdventure.Xna.Constants.MessageRenderer.Input.NextAnswerKey, TextAdventure.Xna.Constants.MessageRenderer.Input.PreviousAnswerKey); _scrollKeyboardStateHelper = new KeyboardStateHelper( _scrollKeyboardRepeatHelper, TextAdventure.Xna.Constants.MessageRenderer.Input.ScrollUpKey, TextAdventure.Xna.Constants.MessageRenderer.Input.ScrollDownKey, TextAdventure.Xna.Constants.MessageRenderer.Input.HomeKey, TextAdventure.Xna.Constants.MessageRenderer.Input.EndKey, TextAdventure.Xna.Constants.MessageRenderer.Input.PageUpKey, TextAdventure.Xna.Constants.MessageRenderer.Input.PageDownKey); _scrollKeyboardRepeatHelper.InitialInterval = TextAdventure.Xna.Constants.MessageRenderer.Input.ScrollKeyboardInterval; _scrollKeyboardRepeatHelper.RepeatingInterval = TextAdventure.Xna.Constants.MessageRenderer.Input.ScrollKeyboardInterval; }
/// <summary> /// Tworzy nowy podział świata /// </summary> /// <param name="world">świat</param> /// <param name="maxPartition">maksymalna liczba podziałów na osi</param> public Heuristics(WorldInstance world, int maxPartition) { _world = world; if (world.SizeX >= world.SizeY) { PartitionX = maxPartition; PartitionSize = world.SizeX/(double)PartitionX; PartitionY = (int) Math.Round(world.SizeY/PartitionSize); } else { PartitionY = maxPartition; PartitionSize = world.SizeY / (double)PartitionY; PartitionX = (int)Math.Round(world.SizeX / PartitionSize); } PartitionRadius = Math.Sqrt(2*PartitionSize*PartitionSize)/2; CalculateLenghts(); CalculatePartitionning(); CalculateAccessibility(); //CalculateRealDistances(); world.heuristic = this; }
public static Quest MakeRandomQuest(Entity questor, Entity provider, WorldInstance overworldRef) { List <QuestStep> steps = new List <QuestStep>(); //int numberOfSteps = RNG.Roll(1, 4); int numberOfSteps = 1; for (int i = 0; i < numberOfSteps; i++) { int result = RNG.Roll(0, 3); switch (result) { case (int)QuestAction.Deliver: steps.Add(MakeDeliveryQuest(provider, overworldRef)); break; case (int)QuestAction.Retrieve: steps.Add(MakeRetrieveQuest(provider, overworldRef)); break; case (int)QuestAction.Destroy: steps.Add(MakeDestroyQuest(provider, overworldRef)); break; case (int)QuestAction.Explore: steps.Add(MakeExploreQuest(provider, overworldRef)); break; } } return(new Quest(steps, QuestMorality.Neutral, GetRewards(questor, provider, steps))); }
public static QuestStep MakeRetrieveQuest(Entity provider, WorldInstance overworldRef) { QuestAction action = QuestAction.Retrieve; ItemInstance target = null; int breakout = 0; while (breakout < 100) { Entity holder = overworldRef.GetRandomSentientWorldWide(); if (holder.Backpack.Count > 0) { int result = RNG.Roll(0, holder.Backpack.Count - 1); target = holder.Backpack[result]; break; } breakout += 1; } if (breakout == 100) { return(MakeExploreQuest(provider, overworldRef)); } QuestStep step = new QuestStep(action, new List <ItemInstance>() { target }, new List <JoyObject>() { provider }, new List <World.WorldInstance>()); return(step); }
public MessageInputHandler(WorldInstance worldInstance, MessageRendererState messageRendererState, TimeSpan totalTime, Action <IXnaGameTime> messageClosingDelegate) { worldInstance.ThrowIfNull("worldInstance"); messageRendererState.ThrowIfNull("messageRendererState"); messageClosingDelegate.ThrowIfNull("messageClosingDelegate"); _worldInstance = worldInstance; _messageRendererState = messageRendererState; _messageClosingDelegate = messageClosingDelegate; _answerKeyboardStateHelper = new KeyboardStateHelper( KeyDown, null, null, TextAdventure.Xna.Constants.MessageRenderer.Input.AcceptKey, TextAdventure.Xna.Constants.MessageRenderer.Input.NextAnswerKey, TextAdventure.Xna.Constants.MessageRenderer.Input.PreviousAnswerKey); _scrollKeyboardStateHelper = new KeyboardStateHelper( _scrollKeyboardRepeatHelper, TextAdventure.Xna.Constants.MessageRenderer.Input.ScrollUpKey, TextAdventure.Xna.Constants.MessageRenderer.Input.ScrollDownKey, TextAdventure.Xna.Constants.MessageRenderer.Input.HomeKey, TextAdventure.Xna.Constants.MessageRenderer.Input.EndKey, TextAdventure.Xna.Constants.MessageRenderer.Input.PageUpKey, TextAdventure.Xna.Constants.MessageRenderer.Input.PageDownKey); _scrollKeyboardRepeatHelper.InitialInterval = TextAdventure.Xna.Constants.MessageRenderer.Input.ScrollKeyboardInterval; _scrollKeyboardRepeatHelper.RepeatingInterval = TextAdventure.Xna.Constants.MessageRenderer.Input.ScrollKeyboardInterval; }
/// <summary> /// Create a new entity, naked and squirming /// Created with no equipment, knowledge, family, etc /// </summary> /// <param name="template"></param> /// <param name="needs"></param> /// <param name="level"></param> /// <param name="job"></param> /// <param name="sex"></param> /// <param name="sexuality"></param> /// <param name="position"></param> /// <param name="icons"></param> /// <param name="world"></param> public Entity(EntityTemplate template, Dictionary <NeedIndex, EntityNeed> needs, int level, JobType job, Sex sex, Sexuality sexuality, Vector2Int position, List <Sprite> sprites, WorldInstance world) : base(NameProvider.GetRandomName(template.CreatureType, sex), template.Statistics[StatisticIndex.Endurance].Value * 2, position, sprites, template.JoyType, true) { this.CreatureType = template.CreatureType; this.m_Size = template.Size; this.Slots = template.Slots; this.m_JobLevels = new Dictionary <string, int>(); this.m_Sexuality = sexuality; this.m_IdentifiedItems = new List <string>(); this.m_Statistics = template.Statistics; if (template.Skills.Count == 0) { this.m_Skills = EntitySkillHandler.GetSkillBlock(needs); } else { this.m_Skills = template.Skills; } this.m_Needs = needs; this.m_Abilities = template.Abilities; this.m_Level = level; for (int i = 1; i < level; i++) { this.LevelUp(); } this.m_Experience = 0; this.m_CurrentJob = job; this.m_Sentient = template.Sentient; this.m_NaturalWeapons = NaturalWeaponHelper.MakeNaturalWeapon(template.Size); this.m_Equipment = new Dictionary <string, ItemInstance>(); this.m_Backpack = new List <ItemInstance>(); this.m_Relationships = new Dictionary <long, int>(); this.Sex = sex; this.m_Family = new Dictionary <long, RelationshipStatus>(); this.m_VisionType = template.VisionType; this.m_Tileset = template.Tileset; this.CalculateDerivatives(); this.m_Vision = new bool[1, 1]; this.m_Pathfinder = new Pathfinder(); this.m_PathfindingData = new Queue <Vector2Int>(); this.m_FulfillingNeed = (NeedIndex)(-1); this.m_FulfilmentCounter = 0; this.RegenTicker = RNG.Roll(0, REGEN_TICK_TIME - 1); this.MyWorld = world; SetFOVHandler(); SetCurrentTarget(); }
public SimulationThreadInfo(Socket udpclient, Thread simulationthread, WorldInstance worldinstance, IPEndPoint broadcastendpoint, System.Timers.Timer networksendtimer) { udpSocket = udpclient; simulationThread = simulationthread; worldInstance = worldinstance; broadcastEndPoint = broadcastendpoint; networkSendTimer = networksendtimer; }
private static void LinkWorlds(WorldInstance parent) { foreach (WorldInstance world in parent.Areas.Values) { world.Parent = parent; LinkWorlds(world); } }
public static void GenerateRumours(WorldInstance worldRef) { s_Rumours = new List <string>(); for (int i = 0; i < 12; i++) { s_Rumours.Add(CreateRumour(worldRef)); } }
public static WorldInstance GenerateDungeon(string name, int size, int levels, params string[] dungeonTypes) { DungeonInteriorGenerator interiorGenerator = new DungeonInteriorGenerator(); SpawnPointPlacer spawnPointPlacer = new SpawnPointPlacer(); List <string> entitiesToPlace = new List <string>(); if (dungeonTypes != null) { entitiesToPlace.AddRange(dungeonTypes); } WorldInstance root = null; WorldInstance current = null; for (int i = 1; i <= levels; i++) { WorldTile[,] tiles = interiorGenerator.GenerateWorldSpace(size); WorldInstance worldInstance = new WorldInstance(tiles, WorldType.Interior, name + " " + i); List <JoyObject> walls = interiorGenerator.GenerateWalls(tiles); foreach (JoyObject wall in walls) { worldInstance.AddObject(wall); } List <ItemInstance> items = DungeonItemPlacer.PlaceItems(worldInstance); foreach (ItemInstance item in items) { worldInstance.AddObject(item); } List <Entity> entities = DungeonEntityPlacer.PlaceEntities(worldInstance, entitiesToPlace); foreach (Entity entity in entities) { worldInstance.AddEntity(entity); } //Do the spawn points worldInstance.SpawnPoint = spawnPointPlacer.PlaceSpawnPoint(worldInstance); //Use this as our root if we don't have one if (root == null) { root = worldInstance; } //Link to the previous floor if (current != null) { current.AddArea(worldInstance.SpawnPoint, worldInstance); } current = worldInstance; } return(root); }
public CommandQueue(IWorldObserver worldObserver, WorldInstance worldInstance) { _worldObserver = worldObserver; _worldInstance = worldInstance; worldObserver.ThrowIfNull("worldObserver"); worldInstance.ThrowIfNull("worldInstance"); _context = new CommandContext(_worldInstance, this); _commandList = new CommandList(worldObserver, _context); }
private void ContinueGame(object sender, EventArgs eventArgs) { WorldInstance overworld = WorldSerialiser.Deserialise("Everse"); Done = true; WorldInstance playerWorld = overworld.Player.MyWorld; m_NextState = new WorldState(overworld, playerWorld, Gameplay.GameplayFlags.Moving); }
public static int GetNumberOfFloors(int floorsSoFar, WorldInstance worldToCheck) { if (worldToCheck.Areas.Count > 0) { foreach (WorldInstance world in worldToCheck.Areas.Values) { return(GetNumberOfFloors(floorsSoFar + 1, world)); } } return(floorsSoFar); }
public PlayerInputHandler(WorldInstance worldInstance) { worldInstance.ThrowIfNull("worldInstance"); _worldInstance = worldInstance; _keyboardStateHelper = new KeyboardStateHelper( _keyboardRepeatHelper, Constants.PlayerRenderer.Input.MoveUpKey, Constants.PlayerRenderer.Input.MoveDownKey, Constants.PlayerRenderer.Input.MoveLeftKey, Constants.PlayerRenderer.Input.MoveRightKey); }
public WorldState(WorldInstance overworldRef, WorldInstance activeWorldRef, GameplayFlags flagsRef) : base() { m_ActiveWorld = activeWorldRef; m_GameplayFlags = flagsRef; m_Overworld = overworldRef; m_Camera = GameObject.Find("Main Camera").GetComponent <Camera>(); m_FogOfWarHolder = GameObject.Find("WorldFog"); m_EntitiesHolder = GameObject.Find("WorldEntities"); m_InventoryOpen = false; }
private static void EntityWorldKnowledge(WorldInstance parent) { foreach (Entity entity in parent.Entities) { entity.MyWorld = parent; } foreach (WorldInstance world in parent.Areas.Values) { EntityWorldKnowledge(world); } }
protected void SetEntityWorld(WorldInstance world) { for (int i = 0; i < world.Entities.Count; i++) { world.Entities[i].MyWorld = world; } foreach (WorldInstance nextWorld in world.Areas.Values) { SetEntityWorld(nextWorld); } }
public bool AddItemToWorld(WorldInstance world, Guid GUID) { if (!this.LiveItems.ContainsKey(GUID)) { return(false); } IItemInstance item = this.Get(GUID); item.MyWorld = world; world.AddItem(item); return(true); }
public static WorldInstance Deserialise(string worldName) { StreamReader reader = new StreamReader(Directory.GetCurrentDirectory() + "/save/" + worldName + "/sav.dat"); string worldString = reader.ReadToEnd(); WorldInstance world = JsonUtility.FromJson <WorldInstance>(worldString); LinkWorlds(world); EntityWorldKnowledge(world); AssignIcons(world); reader.Close(); return(world); }
public Entity Create(EntityTemplate template, Dictionary <NeedIndex, EntityNeed> needs, int level, JobType job, Sex sex, Sexuality sexuality, Vector2Int position, List <Sprite> sprites, WorldInstance world) { Entity entity = new Entity(template, needs, level, job, sex, sexuality, position, sprites, world); m_Entities.Add(entity.GUID, entity); if (entity.PlayerControlled) { m_Player = entity; } return(entity); }
public override Vector3D TraceRay(ref Ray TestRay) { ShadeRec SR = WorldInstance.HitBareBoneObjects(ref TestRay); if (SR.HitAnObject) { SR.Ray = TestRay; return(SR.Material.Shading(ref SR)); } else { return(WorldInstance.BackgroundColor); } }
void worldInstance_OnUpdate(WorldInstance me, DateTime signaltime) { var info = worldInstanceServers[me.GetHashCode()]; foreach (var npc in info.worldInstance.npcs) { info.udpSocket.SendTo(PackageConverter.ConvertToByteArray <ServerPlayEventPackage>(npc.nextEventPackage), info.broadcastEndPoint); info.udpSocket.SendTo(PackageConverter.ConvertToByteArray <ServerPlayStatePackage>(npc.nextStatePackage), info.broadcastEndPoint); } foreach (var player in info.worldInstance.players.Values) { info.udpSocket.SendTo(PackageConverter.ConvertToByteArray <ServerPlayEventPackage>(player.nextEventPackage), info.broadcastEndPoint); info.udpSocket.SendTo(PackageConverter.ConvertToByteArray <ServerPlayStatePackage>(player.nextStatePackage), info.broadcastEndPoint); } }
public Entity CreateLong(EntityTemplate template, Dictionary <NeedIndex, EntityNeed> needs, int level, float experience, JobType job, Sex sex, Sexuality sexuality, Vector2Int position, List <Sprite> sprites, ItemInstance naturalWeapons, Dictionary <string, ItemInstance> equipment, List <ItemInstance> backpack, Dictionary <long, int> relationships, List <string> identifiedItems, Dictionary <long, RelationshipStatus> family, Dictionary <string, int> jobLevels, WorldInstance world, string tileset) { Entity entity = new Entity(template, needs, level, experience, job, sex, sexuality, position, sprites, naturalWeapons, equipment, backpack, relationships, identifiedItems, family, jobLevels, world, tileset); m_Entities.Add(entity.GUID, entity); if (entity.PlayerControlled) { m_Player = entity; } return(entity); }
public Vector2Int PlaceTransitionPoint(WorldInstance worldRef) { int breakout = (worldRef.Tiles.GetLength(0) * worldRef.Tiles.GetLength(1)) / 4; int x, y; x = RNG.Roll(1, worldRef.Tiles.GetLength(0) - 1); y = RNG.Roll(1, worldRef.Tiles.GetLength(1) - 1); Vector2Int point = new Vector2Int(x, y); int count = 0; while (worldRef.Walls.Keys.Any(l => l == point) && (point.x != worldRef.SpawnPoint.x && point.y != worldRef.SpawnPoint.y || count < breakout)) { x = RNG.Roll(1, worldRef.Tiles.GetLength(0) - 1); y = RNG.Roll(1, worldRef.Tiles.GetLength(1) - 1); point = new Vector2Int(x, y); count += 1; } Pathfinder pathfinder = new Pathfinder(); Queue <Vector2Int> points = pathfinder.FindPath(point, worldRef.SpawnPoint, worldRef); if (points.Count > 0) { return(point); } else { count = 0; while (worldRef.Walls.Keys.Any(l => l == point) && (point.x != worldRef.SpawnPoint.x && point.y != worldRef.SpawnPoint.y || count < breakout)) { x = RNG.Roll(1, worldRef.Tiles.GetLength(0) - 1); y = RNG.Roll(1, worldRef.Tiles.GetLength(1) - 1); point = new Vector2Int(x, y); count += 1; } } return(new Vector2Int(-1, -1)); }
public Vector2Int PlaceSpawnPoint(WorldInstance worldRef) { int x, y; x = RNG.Roll(1, worldRef.Tiles.GetLength(0) - 1); y = RNG.Roll(1, worldRef.Tiles.GetLength(1) - 1); Vector2Int point = new Vector2Int(x, y); while (worldRef.Walls.Keys.Any(l => l.Equals(point))) { x = RNG.Roll(1, worldRef.Tiles.GetLength(0) - 1); y = RNG.Roll(1, worldRef.Tiles.GetLength(1) - 1); point = new Vector2Int(x, y); } return(point); }
public CommandContext(WorldInstance worldInstance, CommandQueue commandQueue) : base(worldInstance, commandQueue) { }
private bool LoadData() { _generations = 0; label13.Text = ""; label14.Text = ""; label15.Text = ""; label16.Text = ""; label17.Text = ""; label18.Text = ""; labelGAll.Text = @"0"; try { _world = new WorldInstance(comboBox1.Text); var x = _world.Specification.Spec.Map(s => s.Length);// Func<NodeSpec, double>{s => s}) //TODO _world.heuristic = new Heuristics(_world, (int)numericUpDown2.Value); _baseImage = new Bitmap(_world.ShowWorld(pictureBox1.Width, pictureBox1.Height, 2.0f)); _populationSize = (int) numericUpDown1.Value; _badguys = (double) numericUpDown3.Value/100; _mutChance = (double)numericUpDown4.Value / 100; _showbest = (int) numericUpDown7.Value; _adjustment = (double) numericUpDown5.Value/100; _tournament = (int) numericUpDown2.Value; _explicite = (double)numericUpDown6.Value / 100; _mutationId = comboBox2.SelectedIndex; _crossoverId = comboBox3.SelectedIndex; _evaluationId = comboBox4.SelectedIndex; } catch (Exception e) { label5.ForeColor = Color.Red; label5.Text = e.Message; return false; } label5.ForeColor = Color.Green; label5.Text = @"Scenariusz wczytany poprawnie."; return true; }
public MessageMananger(WorldInstance worldInstance) { _worldInstance = worldInstance; }
public PartitionHeuristic(Point center, double radius, WorldInstance world, double maxArmLen, double minArmLen, List<double> maxFingersLen, List<double> minFingersLen) { SLDistanceStart = Geometry.SLDistance(center, world.Start); Center = center; Radius = radius; foreach (var t in world.Targets) SLDistanceTargets.Add(Geometry.SLDistance(center, t)); ReachableStart = SLDistanceStart + radius >= minArmLen && SLDistanceStart - radius <= maxArmLen; for (var i = 0; i < world.Targets.Count; i++) { ReachableTargets.Add(new List<bool>()); for(int j = 0; j < world.Targets.Count; j++) ReachableTargets[i].Add(SLDistanceTargets[i] + radius >= minFingersLen[i] && SLDistanceTargets[i] - radius <= maxFingersLen[i]); } var perm = Geometry.Permutations(world.Targets.Count); foreach (var p in perm) { var b = true; for (var i = 0; i < world.Targets.Count; i++) b &= ReachableTargets[i][p[i]]; if (b) PossibleFingering.Add(p); } }