Posts

Week 10. Finding the exit algorithm

This weekend I worked on the algorithm for finding the fastest root from start to the exit room of the level. Today competed the code and it worked.

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 ...