Graal Forums  

Go Back   Graal Forums > Development Forums > Level Design
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #16  
Old 11-24-2013, 06:12 PM
jacob_bald6225 jacob_bald6225 is offline
Doctor Who?
jacob_bald6225's Avatar
Join Date: Feb 2002
Posts: 851
jacob_bald6225 is a splendid one to beholdjacob_bald6225 is a splendid one to beholdjacob_bald6225 is a splendid one to beholdjacob_bald6225 is a splendid one to behold
Quote:
Originally Posted by Emera View Post
It actually takes a tremendous amount of time, but I wasn't expecting anything else. Regarding dealing with tile obscurities though, it has been suggested that I use an algorithm to check for similarities between tiles instead of directly comparing pixel data. Obviously, it's not fool proof and I doubt I'm capable of coming up with something that is, but it's a step in the right direction
I think mine got down to something insane like 20 seconds for a level the more I worked with it and changed how I did things.


I am a noob but heres kind of some rambling advice as to how I was doing it and saving time.

Each scan read the r,g,b color of each tile in an X(Top left to bottom right, top right to bottom left). That is scanning 32 pixels per tiles instead of 256 (all of them)-- this increased my speed by 8 times.

I stored that in a big array from the tileset.


The scanning of the level is where time was made up:
Then when scanning the level I scanned 0,0-- looped through and checked it against the array of the tileset tiles. If a match was found-- I reorganized the tileset array of tiles to move the tile that was found to the 0 position. That way, common tiles in the level are closer to the first checked.

If a tile wasn't found-- I put it in a "not found" array. Which it'd scan before the tileset. Since there usually weren't 100s of not found tiles this stopped the thing from looping through all 4000 or so tiles each time one wasn't found.
__________________
Reply With Quote
  #17  
Old 11-26-2013, 03:15 PM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
Quote:
Originally Posted by jacob_bald6225 View Post
I think mine got down to something insane like 20 seconds for a level the more I worked with it and changed how I did things.


I am a noob but heres kind of some rambling advice as to how I was doing it and saving time.

Each scan read the r,g,b color of each tile in an X(Top left to bottom right, top right to bottom left). That is scanning 32 pixels per tiles instead of 256 (all of them)-- this increased my speed by 8 times.

I stored that in a big array from the tileset.


The scanning of the level is where time was made up:
Then when scanning the level I scanned 0,0-- looped through and checked it against the array of the tileset tiles. If a match was found-- I reorganized the tileset array of tiles to move the tile that was found to the 0 position. That way, common tiles in the level are closer to the first checked.

If a tile wasn't found-- I put it in a "not found" array. Which it'd scan before the tileset. Since there usually weren't 100s of not found tiles this stopped the thing from looping through all 4000 or so tiles each time one wasn't found.
You've suggested some nice ideas here. Yeah, the time it takes to initially scan through to find matches takes forever. Right now I'm doing something like this:
  1. Add bitmap data for each tile on the tileset to a list
  2. Grab the bitmap data of each tile in the level image and generate a hash for comparrison using the following method.

    HTML Code:
    private unsafe string GetPixelHash(BitmapData bd)
    {
        string final = "";
    
        for (int y = 0; y < bd.Height; y++)
        {
            byte* row = (byte*)bd.Scan0 + (y * bd.Stride);
            for (int x = 0; x < bd.Width; x++)
            {
                final += row[x * 4].ToString();
            }
        }
    
        return final;
    }
  3. Cross compare
  4. Get tileset position of tiles
  5. Generate

Quite obviously a much more efficient method of comparison is possible since you've said that it's possible to cut down the generation time to around 20~ seconds. In my defence though, the code hasn't been re-written at all so you're really looking at my preliminary method at work!
__________________
Reply With Quote
  #18  
Old 11-27-2013, 07:32 PM
jacob_bald6225 jacob_bald6225 is offline
Doctor Who?
jacob_bald6225's Avatar
Join Date: Feb 2002
Posts: 851
jacob_bald6225 is a splendid one to beholdjacob_bald6225 is a splendid one to beholdjacob_bald6225 is a splendid one to beholdjacob_bald6225 is a splendid one to behold
Quote:
Originally Posted by Emera View Post
You've suggested some nice ideas here. Yeah, the time it takes to initially scan through to find matches takes forever. Right now I'm doing something like this:

--

Quite obviously a much more efficient method of comparison is possible since you've said that it's possible to cut down the generation time to around 20~ seconds. In my defence though, the code hasn't been re-written at all so you're really looking at my preliminary method at work!
Mine was a bunch of tard-code. So if you work hard at it I'm sure you can do better!

Also you could pretty easily use the streamwriter class and pump out .nw levels too!

http://www.dotnetperls.com/streamwriter
__________________
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 01:45 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.