public static PheromoneDescriptor FromDigest(PheromoneDigest digest) { if (digest == null) { return(null); } return(new PheromoneDescriptor(digest.type, digest.direction)); }
private void MakeAntThink(Ant ant, AntAI ai) { // Inserts the ant randomly in the next turn InsertAntInNextRandomList(ant); // Gets all the pheromones on the current tile List <PheromoneDigest> pheromones = PheromoneDigest.ListFromDescriptorList(pheromoneMaps[ant.team.teamId][ant.gameCoordinates.x][ant.gameCoordinates.y]); // Gets all the surrounding pheromones Dictionary <HexDirection, List <PheromoneDigest> > pheromoneGroups = new Dictionary <HexDirection, List <PheromoneDigest> >(); for (HexDirection direction = (HexDirection)1; (int)direction < 7; direction++) { Vector2Int currentCoord = CoordConverter.MoveHex(ant.gameCoordinates, direction); if (!CheckCoordinatesValidity(currentCoord)) { pheromoneGroups.Add(direction, PheromoneDigest.ListFromDescriptorList(null)); } else { pheromoneGroups.Add(direction, PheromoneDigest.ListFromDescriptorList(pheromoneMaps[ant.team.teamId][currentCoord.x][currentCoord.y])); } } TurnInformation info = new TurnInformation( terrain[ant.gameCoordinates.x][ant.gameCoordinates.y].tile.Type, ant.pastTurn != null ? ant.pastTurn.DeepCopy() : null, ant.mindset, pheromones, pheromoneGroups, ValueConverter.Convert(ant.energy), ValueConverter.Convert(ant.hp), ValueConverter.Convert(ant.carriedFood), ant.analyseReport, ant.communicateReport, ant.eventInputs, ant.GetInstanceID() ); if (ant.Type == AntType.QUEEN) { ant.decision = ai.OnQueenTurn(info); } else if (ant.Type == AntType.WORKER) { ant.decision = ai.OnWorkerTurn(info); } else { Debug.LogError("This ant has an unknown type!"); } if (ant.decision == null) { ant.decision = new Decision(ant.mindset, ChoiceDescriptor.ChooseNone(), pheromones); } ant.displayDirection = ant.decision.choice.direction; ant.ClearInputs(); // The inputs are flushed here so they can be filled up by the resolution of the actions }