public void ChangeRoom(int portalID, int destinationID) { // HACK PROTOTYPE manual manipulation of saving vars generatedImagesSelectedID = portalID; generatedImagesCounter++; generatedSculpturesCounter++; // is the desitnation a new room or a return? if (room.GetRoomByPortalID(portalID) == null) { UnityEngine.Debug.Log("Making new room..."); room.AddRoom(portalID, new RoomConfiguration(room, destinationID, portalID, room.GetArtworks(), room.sculptures)); } else { room.MutateSculptures(); } room = room.GetRoomByPortalID(portalID); gameRoom.ConfigureRoom(room.GetParentID(), GetImagesFromArtworks(room.GetArtworks()), room.sculptures); gameRoom.RedrawRoom(); gameRoom.ClearReturnPortalDecorations(); if (room.GetParentID() > -1) { gameRoom.SetReturnPortalDecoration(room.GetParentID()); } SaveRoom(); }
static void Main(string[] args) { Console.WriteLine("Setup DB"); var rc = new RoomConfiguration(); // appsettings.json based config identical to those used in the service layer var builder = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json"); DbConfiguration = builder.Build(); Console.WriteLine($"Create Db for {DbConfiguration.GetConnectionString(nameof(PersonalManagerContext))}"); // Create DB and check model using (var context = new PersonalManagerContext(DbConfiguration)){ context.Database.EnsureDeleted(); context.Database.EnsureCreated(); // add seed data for demo context.Set <Employee>().Add(new Employee { Name = "Ermin Employee", EmployeeNumber = "A123456" }); context.SaveChanges(); // force model to be created in memory for testing var model = context.Set <Employee>().ToList(); System.Console.WriteLine(model.Count()); // for more testing see unit tests } Console.WriteLine("Done"); Console.ReadLine(); }
private int MUTATION_CYCLES = 12; // maximum mutations per evolution public RoomConfiguration(RoomConfiguration parentRoom, int returnPortalID, int championPortalID, Artwork[] artworksPassed, Sculpture[] sculptures) { ArtGallery ag = ArtGallery.GetArtGallery(); Artwork champion = artworksPassed[championPortalID]; if (ArtGallery.DEBUG_LEVEL < ArtGallery.DEBUG.NONE) { Debug.Log("Creating a new room with " + artworksPassed.Length + " artworks"); } this.parentRoom = parentRoom; rooms = new RoomConfiguration[artworksPassed.Length]; if (ArtGallery.DEBUG_LEVEL < ArtGallery.DEBUG.NONE) { Debug.Log("Clearing artworks and sculptures..."); } artworks = new Artwork[artworksPassed.Length]; this.sculptures = sculptures; if (ArtGallery.DEBUG_LEVEL < ArtGallery.DEBUG.NONE) { Debug.Log("Created new artworks: " + artworksPassed.Length); } rooms[returnPortalID] = parentRoom; // clone champion to each artwork and mutate for (int i = 0; i < artworksPassed.Length; i++) { TWEANNGenotype geno = new TWEANNGenotype(champion.GetGenotype().Copy()); // champion art if (i == championPortalID) { //do little geno.Mutate(); } // return art else if (i == returnPortalID) { // do nothing - save some cpu } else { // all other art TWEANNCrossover cross = new TWEANNCrossover(false) { Sucessful = false }; //HACK PROTOTYPE hardcoded value //TWEANNGenotype crossedGeno = cross.Crossover(new TWEANNGenotype(geno.Copy()), new TWEANNGenotype(champion.GetGenotype().Copy())); //geno = crossedGeno; for (int m = 0; m < Random.Range(2, ag.artworkMutationChances); m++) { geno.Mutate(); } } artworks[i] = new Artwork(geno); } MutateSculptures(); }
public async Task <ActionResult> CreateRoom(RoomConfiguration roomConfiguration, string ownerColor) { var room = roomService.CreateRoom(roomConfiguration, GameType, ownerColor); await roomService.SetRoom(room); return(Ok(room)); }
public void Instance_Is_CreatorConfiguration_Of_TypeOfRoom() { //Arrange var type = typeof(TravelTypeConfiguration <Room>); //Act var configuration = new RoomConfiguration(); //Assert Assert.IsInstanceOf(type, configuration); }
public RoomConfiguration GetRoomByArtwork(Artwork champion) { RoomConfiguration result = null; for (int a = 0; a < artworks.Length; a++) { if (artworks[a] == champion) { result = rooms[a]; } break; } return(result); }
// Use this for initialization void Start() { artgallery = this; //FIXME PROTOTYPE set a random seed value here instead and save that value for a play session seed = testerID; //testerID //seed = UnityEngine.Random.Range(0, 9999999); UnityEngine.Random.InitState(seed); //RunExternalScript("test.bat", ""); // Build the game room GameObject roomProp = Instantiate(roomObject) as GameObject; gameRoom = roomProp.GetComponent <Room>(); gameRoom.SetArtGallery(this); // starting functions availableFunctions = new List <FTYPE> { FTYPE.ID, FTYPE.TANH, FTYPE.SQUAREWAVE, FTYPE.GAUSS, FTYPE.SINE, FTYPE.SAWTOOTH, FTYPE.ABSVAL }; if (activeFunctions == null) { activeFunctions = new List <FTYPE>(); ActivateFunction(FTYPE.ID); } //activate functions // Testing: activating all functions //ActivationFunctions.ActivateAllFunctions(); ActivationFunctions.ActivateFunction(activeFunctions); // build the lobby lobby = new RoomConfiguration(STARTING_NUM_ARTWORKS); room = lobby; gameRoom.InitializeRoom(GetImagesFromArtworks(room.GetArtworks())); List <Artwork> artToSave = new List <Artwork>(); lobby.SetSculptures(gameRoom.GetSculptures()); }
/// <summary> /// Requests that the system create blank files for a new project. /// </summary> internal static void CreateTemplateFiles() { #region Write Configuration PronounGroup.PutRecords(Enumerable.Empty <PronounGroup>()); BiomeConfiguration.PutRecord(); CraftConfiguration.PutRecord(); InventoryConfiguration.PutRecord(); RoomConfiguration.PutRecord(); #endregion #region Write Models ModelCollection <GameModel> .Default.PutRecordsForType <GameModel>(); ModelCollection <ParquetModel> .Default.PutRecordsForType <FloorModel>(); ModelCollection <ParquetModel> .Default.PutRecordsForType <BlockModel>(); ModelCollection <ParquetModel> .Default.PutRecordsForType <FurnishingModel>(); ModelCollection <ParquetModel> .Default.PutRecordsForType <CollectibleModel>(); ModelCollection <BeingModel> .Default.PutRecordsForType <CritterModel>(); ModelCollection <BeingModel> .Default.PutRecordsForType <CharacterModel>(); ModelCollection <BiomeRecipe> .Default.PutRecordsForType <BiomeRecipe>(); ModelCollection <CraftingRecipe> .Default.PutRecordsForType <CraftingRecipe>(); ModelCollection <RoomRecipe> .Default.PutRecordsForType <RoomRecipe>(); ModelCollection <RegionModel> .Default.PutRecordsForType <RegionModel>(); ModelCollection <ScriptModel> .Default.PutRecordsForType <ScriptModel>(); ModelCollection <InteractionModel> .Default.PutRecordsForType <InteractionModel>(); ModelCollection <ItemModel> .Default.PutRecordsForType <ItemModel>(); #endregion }
public Room CreateRoom(RoomConfiguration roomConfiguration, GameType gameType, string ownerColor) { var room = new Room { RoomConfiguration = roomConfiguration, Players = new List <Player>(roomConfiguration.NumberOfPlayers), GameType = gameType, IsFull = false }; room.RoomConfiguration.NumberOfPlayers = 2; room.Players.Add(new Player { Id = roomConfiguration.PlayerOwnerId, Name = roomConfiguration.PlayerOwnerName, Color = ownerColor }); var playerEmptyPoints = room.Players.ToDictionary(player => player.Id, _ => 0); var gameTask = new GameTask ( new ChessGameStatus { WhiteClock = room.RoomConfiguration.RoundDuration, BlackClock = room.RoomConfiguration.RoundDuration }, new Game { Id = Guid.NewGuid().ToString(), Room = room, PlayersPointsPerGame = playerEmptyPoints } ); gameHelper.gameTasks.Add(gameTask); return(room); }
public Room CreateRoom(RoomConfiguration roomConfiguration, GameType gameType) { var room = new Room { RoomConfiguration = roomConfiguration, Players = new List <Player>(2), GameType = gameType, IsFull = false }; room.Players.Add(new Player { Id = roomConfiguration.PlayerOwnerId, Name = roomConfiguration.PlayerOwnerName }); var playerEmptyPoints = new Dictionary <string, int>(); foreach (var item in room.Players) { playerEmptyPoints.Add(item.Id, 0); } var gameTask = new GameTask ( new ShipsGameStatus(), new Common.Models.ShipsGame { Id = Guid.NewGuid().ToString(), Room = room, PlayersPointsPerGame = playerEmptyPoints, Players = new List <string>() } ); gameHelper.gameTasks.Add(gameTask); return(room); }
private void SetUpRoom(RoomConfiguration room) { var x = room.entities.Length; var y = room.entities[0].Length; multiplier = 5f / Mathf.Max(x, y); grid.cellSize = Vector3.one * multiplier; matrix = new Entity[x, y]; if (x % 2 != 0) { transform.position = new Vector3(-0.5f * multiplier, transform.position.y, 0); } if (y % 2 != 0) { transform.position = new Vector3(transform.position.x, -0.5f * multiplier, 0); } for (var i = 0; i < x; i++) { for (var j = 0; j < y; j++) { DrawCell(i, j, x, y); GameObject g = null; switch (room.entities[i][j]) { case RoomConfiguration.TileType.Empty: continue; case RoomConfiguration.TileType.Enemy: g = Instantiate(enemyPrefab); break; case RoomConfiguration.TileType.Wall: g = Instantiate(wallPrefab); break; case RoomConfiguration.TileType.Player: g = Instantiate(playerPrefab); break; case RoomConfiguration.TileType.Portal: winCoordinates = new Vector2Int(i, j); g = Instantiate(portalPrefab); break; case RoomConfiguration.TileType.Ogre: g = Instantiate(ogrePrefab); break; case RoomConfiguration.TileType.Fire: g = Instantiate(firePrefab); break; default: throw new ArgumentOutOfRangeException(); } var location = grid.GetCellCenterWorld(new Vector3Int(i - x / 2, (j - y / 2) * -1, 0)); g.transform.position = location; g.transform.localScale *= multiplier; g.transform.SetParent(root.transform); if (room.entities[i][j] == RoomConfiguration.TileType.Portal) { continue; } matrix[i, j] = g.GetComponent <Entity>(); } } }
public void Initialize(RoomConfiguration room) { DestroyAll(); SetUpRoom(room); cardManager.Initialize(room.cards); }
public void AddRoom(int artworkID, RoomConfiguration newRoom) { rooms[artworkID] = newRoom; }
public static void Save(ArtGallery artGallery) { /* roomconfig * artwork[] artworks * - tweanngenotype geno * - list<nodes> nodes * - long innovation * - FTYPE fTYPE * - NTYPE nTYPE * - float bias * - list<links> links * - long innovation * - long sourceInnovation * - long targetInnovation * - float weight * - bool active (not in use) * - long id * - int numberInputs * - int numberOutputs * - int archetypeIndex * sculpture[] sculptures * - tweanngenotype geno * - list<nodes> nodes * - long innovation * - FTYPE fTYPE * - NTYPE nTYPE * - float bias * - list<links> links * - long innovation * - long sourceInnovation * - long targetInnovation * - float weight * - bool active (not in use) * - long id * - int numberInputs * - int numberOutputs * - int archetypeIndex * - bool transparency * Roomconfiguration ParentRoom * RoomConfiguration[] linkedRooms */ //FIXME This needs to be recursive! This will take a bit of planning. // Get the lobby RoomConfiguration lobby = artGallery.GetLobby(); // Build a new save for the room config SaveGameRoomConfiguration newRoom = new SaveGameRoomConfiguration { ParentRoom = null, LinkedRooms = new SaveGameRoomConfiguration[lobby.rooms.Length], Artworks = new SaveGameArtwork[lobby.artworks.Length], //Sculptures = new SaveGameSculpture[lobby.sculptures.Length], }; // Add the rooom roomTree.Add(newRoom); //Now get each linked room to the lobby (traverse the tree) SaveGameRoomConfiguration[] tempLinkedRooms = new SaveGameRoomConfiguration[lobby.rooms.Length]; for (int i = 0; i < tempLinkedRooms.Length; i++) { tempLinkedRooms[i] = new SaveGameRoomConfiguration { ParentRoom = newRoom }; } // Get a reference to the index given to the new room int newRoomIndex = roomTree.IndexOf(newRoom); }
public RoomViewModel(RoomConfiguration roomConfig) { _sourceModel = roomConfig; _sourceModel.PropertyChanged += sourceModel_PropertyChanged; Name = _sourceModel.Name; }