private EncodedWorld Mutate(EncodedWorld worldToMutate) { return(new EncodedWorld(new StringBuilder(worldToMutate.code) { [Random.Range(0, worldToMutate.code.Length)] = RandomElement(POSSIBLE_CELL_VALUES) }.ToString())); }
private WorldMap CreateWorld(EncodedWorld encoded) { var mapSize = (int)Math.Sqrt(encoded.code.Length); var map = new WorldMap(mapSize); for (var i = 0; i < encoded.code.Length; i++) { map.SetCell(InstantiateCell(new Coords(i / mapSize, i % mapSize), encoded.DecodeState(i))); } return(map); }
public void Visualize(EncodedWorld encodedWorld) { DestroyPreviousVisualisation(); var map = encodedWorld.Decode(); foreach (var cell in map.GetCells()) { var cellObject = Instantiate(config.cellPrefab, new Vector3(cell.coords.x + rootCoords.x, 0, cell.coords.z + rootCoords.z), Quaternion.identity, transform); cellObject.gameObject.SetActive(Cell.State.ALIVE.Equals(cell.state)); previousCells.Add(cellObject); } }