Posts

Showing posts from November, 2017

Week 9 Friday Game resetting if Generation failed.

Image
Week 9 Friday Game resetting if Generation failed. Yesterday after writing down the algorithm (for the conditions in which the PLG knows the level has failed) I implemented and it worked with the first attempt. Next up was a way to reset and start again the level generation. the most painless process is reloading the scene so you reset the variables and make sure all components have been deleted.  I encountered a problem though after the initial attempt when the scene is reloaded the source light does not seem to work. I thought for some reason the light needed to be in outside the scene. but that did not seem to work. I also realized that the light source would probably change and it is not needed to be placed at the beginning of the scene but way after after the loot and enemy placement. For visibility though I have scripted so you assign a lightsource prefab that is placed right after we get a good level. Below is a test run were I have put the exit scan line too far awa...

The algorithm for verifying or restarting the PLG.

The algorithm for verifying(success) or restarting(failure) the PLG. With the PLG working correctly, we need to check that the PLG is complete. By complete I mean we need to check that the PLG created fulfills our requirements which are: Reach a minimum percentage of room density  towards the levels size. In other words we want a certain numbers of rooms to fill up the level before we can declare it as finished. Attach to our maze the must included pieces, in my example the Temple Room and the Minotaur Throne Room. these rooms must be attached included in our level. Find a pre-exit room for us to attach our exit room and place the exit. This is how I check those requirements 1)Checking the Density:  The first algorithm required a value X set from the user that indicated after how many tiles placed we should check the density. This was set because the scanning slowed down the process, and there was no point calculating  the density before X tiles. Recentl...

Speeding up the process - Percentage Calculation

Image
Speeding up the process - Percentage Calculation As I am working on the conditions of a successful PLG creation  I thought of a way to optimize the performance of the percentage calculation. Below are a few thoughts and suggestions to me in order to speed up the process. The Density percentage calculation. Initially I scanned the entire area after a set number of tiles to calculate the percentage. If the target density was not reached then we added another 10 tiles and recalculated. Later on I decided once the first scan was completed store only the points that hit nothing, and only scan them, the ones that now hit get removed from the list, So it would start slow and speed up as the percentage grew. This did have an improvement in speed and calculations. I now attempted something even more simple, since the tiles we are placing are premade, we can calculate it's Area and store it. That way every time we add a tile we add that tiles value to the TotalTileArea. The best way ...

Wednesday Week 9 Update. Custom Editor

Image
Custom Editor for PLG. Today I completed the custom editor for the room generator. Generate Level script settings The Custom editor for Generate rooms I made this is the first time that I have used a script for altering the editor appearance. The  differences and benefits are clearly obvious. It is a lot easier to use and find the controls you need. Also to add another scanning line or  must included piece takes one button click rather than increasing the size to 7 lists containing the details. I also set some values when you create a new must include piece. It also assigned a random colour. I must have spent almost one hour to figure out why my colours did not display, and it was because the alpha channel in RGB was set to 0 when it need to be one. Talking about alpha channels I also added a gismo box to the preplaced areas but set the alpha to 0.3 to give it that see-through effect. In regards to coding for the editor, unity has many tools but to prog...

Week 9 Update.

So I am in week 9 and already behind, the maze needs some additional touches and the editor still needs fixing. Were is some of the work still need: Remove exits that have no hope to accommodate another tile( the entrance is placed in front of another piece). After exit is placed Add rooms to outside corridors Add exit gismo path and calculate distance. Add 2 theme spot on room Add theme and percentage to rooms and rules Check for other themes Add theme percentage rules to adjacent rooms. For each room add furniture based on percentage When each tile is placed store if it accepts loot and if it has compulsory loot When each tile is placed store if it accepts enemies and if it has compulsory Enemies Based on dungeon master loot allowance place loot . Based on dungeon master enemies allowance place enemies randomly Editor needs fixing. Week 9 is for catching up. I have also realized that the algorithm that that checks the start to exit distance also is used for...

Outlining the Gui of the dungeon generator 1

Image
I have been away for a weekend but this did not stop me working and researching I need to tidy up my Editor for the dungeon generator Settings. Don't let the title of the above video title fool you it starts out simple but goes into some good depth that I think I will find useful while implementing the custom editor for the Level Generation So while in the plain I made a list of how the attributes/values should be displayed -all subject to change. Gui  dungeon master Slider for room generation visual Tiles to place before first scan int Min Percentage tile/ maze int with range Mazesize x z *(future version might have a button to add more squares will not be implemented in this assignment) Exit scan line with button "add" to add more lines (one available by default) { Starting Scan  Point 1 X Z End scan Point1 X Z } Starting room gameobject Starting position X Z Preplaced tiles "add" button { Gameobject Size of random spawn area ...

A look on how Diablo 3 uses procedural level generation

Image
I found this video of a game I know well, Diablo 3 and it explains how they procedurally generate their levels. Some things I took from this. First based on certain rules they use an algorithm to create a layout on a grid based system. Then place out the sections on the level. This works with their sections all been a specific size. Some open areas in the game are always the same entrance exit, in other words some external maps are premade but they have gaps in them which are filled up with events randomly. I found this useful maybe if in my game I always want them from the beginning to point A, my starting piece could be a prefab of  an entire complex of rooms and corridors(including the starting rooms and the room A) with some random events (or none) . As I am finishing the maze layout I have started to consider for furniture, loot and enemies are distributed. In this video Diablo used preplaced points as potential points for the above to be spawned.  Diablo b...

Week 6-7 Working On the exits.

After

Week 6-7 A Closer look to the Preset pieces alignment.

Image
Week 6-7 A Closer look to the Preset pieces alignment. Something I had in mind when first drafting the algorithm for the PGL was the ability to set certain rooms  in certain areas within the labyrinth. After the completion of the rooms attaching and not overlaping each other, I moved onto the part of including the prep-laced pieces. It is worth to mention that even the pre-placed rooms are not in a constant location but are instantiated within an area set by the user. To set the preset pieces you drag the room to the inspector, set the area dimentions and location where you want it to spawn. I had initially thought to look for open exits close to the open exits of the pre-placed piece and then create a corridor connecting the two exits. But that in its own creates a few new problems: The corridor connecting the two rooms would need to be curved so it would not collide with the rooms and keep the distance of the corridor equal at all points. Also the creation of a code ge...

Week 6-7 Placing the rooms in the labyrinth.

Week 6-7 Placing the rooms in the labyrinth. This update was written 17/11/17. Week 8. Unfortunately this part of the PLG took 3 weeks to complete due to a problem encountered. The first draft of the algorithm was this Place the rooms 1.     Select randomly a open exit in open_exits List. This will be the exit way we attach the next component. 2.     Select randomly between room or corridor. 3.     Select randomly a open exit from the selected room/corridor. 4.     Rotate the the parent room/corridor so it aligns with the selected open exit. 5.     Move the Room so both exits are in the same location. 6.     Check if the placed room collides with an existing room and if it placed outside the layout area. 7.     If any of the above two statements is true then delete the room/corridor. 8.     If not, remove the selected exit from the open_exits lis...

Week 4-5 Generating the Layout

Image
I am writing this in Week 8. Stressed a bit getting everything to work, I preferred to work on the code than write an update in regards to my progress, as I am writing this 17 of November most of the code now works. So my initial idea with the random layout, was to generate a mesh of planes of random size rotation and position to indicate where the rooms can be placed. Bellow is the initial algorithm for the layout generation: Creating the Starting area 1.      Create a plane from the dimensions given for the starting area 2.      Place the starting room in it‘s given location. 3.      Add the starting room's exit point location to the open_exits List. Create the Layout 4.      Create a plane of  random dimentions between 1/32 to 1/64 (theoretical estimate)  of the max area. 5.      Rotate the plane randomly 0-180 degrees. 6.      Sele...

Project Proposal. Week3

Laying out the timetable.  A Project proposal was handed in on week 3. Bellow is a timetable as an indication how the workload will be divided until the hand in date. Teaching week Task Start Date End Date Duration Week 4-5 Create the procedure that creates the layout of the level. 16 October 2017 29 October 2017 14 Week 6-7 Create the function that placed the rooms upon the layout. 30 October 2017 12 November 2017 14 Week 8 Create the function for room randomization by theme. 13 November 2017 19 November 2017 7 Week 9 Blank week to catch-up 20 November 2017 26 November 2017 7 Week 10-11 Examine and measure success and efficiency of the P.L.G. 27 November 2017 10 December 2017 14 Week 12 Collate and finali...