• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Hodgman

Clustering rectangles on a grid

5 posts in this topic

I'm looking for some advice, or even just name-dropping of algorithms or topics to research, in regards to a particular clustering problem.
I did a class on data-mining about 5 years ago, but have pretty much forgotten it all... i.e. I don't really have any theoretical knowledge in the realm of clustering algorithms.


[b]The inputs[/b] to my problem are:
* A grid of some (small) known size, say 50x50 cells.
* Within the grid, many rectangles of varying size/shape -- probably about 1000 of these, but maybe up to 65k max.
[img]http://i.imgur.com/kdeoB.png[/img]


[b]The problem[/b] is that I need to group rectangles together into clusters, where each cluster:
* has a maximum number of members -- e.g. 8 rectangles per cluster.
* the bounds of a cluster is the bounding rectangle of all it's members.
* the bounds should be as small as possible.
* each cell within a cluster's bounding region should contain as many overlapping rectangles ([i]that are members of the cluster[/i]) as possible.
* the above implies that the bounding region should contain as few empty cells as possible.
Also, I'd like to produce as few clusters as possible -- i.e. clusters should contain as many rectangles as possible ([i]up to the maximum member limit above[/i]).

Ideally, I'd like to be able to control/tweak a few heuristics, so I can balance how aggressively the algorithm [i]minimizes empty cells[/i] [b]vs[/b] [i]minimizes cluster count[/i] [b]vs[/b][i] maximizes overlap [/i][b]vs [/b][i]minimizes bounding size[/i], etc...


For example, the above diagram could result in two clusters:
[i][img]http://i.imgur.com/kCMko.png[/img][/i]

Or if avoiding empty cells, it could split the pink/yellow/teal rectangles out into their own single-member clusters, like:
[img]http://i.imgur.com/PWcVM.png[/img]


[size=2][i][b]Off-topic motivation:[/b][/i][/size]
[size=2]The background for this problem is optimizing light splatting in an experimental SM3.0 tiled deferred renderer. Each of the rectangles is the bounds of the screen-space tiles that a particular light will affect. If lights are drawn individually, the g-buffer attributes must be read once per light. However, if overlapping lights are grouped together into a 'cluster light', the G-buffer attributes can instead be read once per cluster.[/size]
0

Share this post


Link to post
Share on other sites
A good source for data mining algorithms is [url="http://www.cs.waikato.ac.nz/ml/weka/"]WEKA[/url].
It is open source so you may find in its source, under clusterers, something useful :)

It is all written in java. Edited by kuramayoko10
1

Share this post


Link to post
Share on other sites
This problem is very similar to the problem when updating a raster display of finding the optimum set of dirty rectangles that need to be blitted that minimize the blitting of pixels that haven't changed. So you might look up published solutions to the dirty rectangle problem (Although I googled around a little bit didn't really find anything)
1

Share this post


Link to post
Share on other sites
Hodgman, what did you end up coming up with regarding an algorithm for this problem? (It kind of interested me, but didn't have time to think about it, so I now I just want to hear what the answer is [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] ) Edited by jwezorek
0

Share this post


Link to post
Share on other sites
Thanks for the replies, I remember using that WEKA software back in university!

@jwezorek, I ended up deciding it was a premature optimisation and basically limiting 'clusters' to the size of a cell [img]http://public.gamedev.net//public/style_emoticons/default/laugh.png[/img]

In terms of the renderer that this was going to be used with -- The CPU collects a list of all lights that overlap each tile in screen space, and then these lists are broken down into groups of 8 (or less) light ID's per tile per pass. The GPU then takes each 'pass' of IDs (up to 8) and checks if those lights actually affect their tile ([i]this time based on min/max depth, which the CPU didn't know[/i]), and outputs a compacted list of IDs ([i]with the non-visible lights removed[/i]). Then when lighting each pass, the tile is discarded if the compacted list is empty, otherwise it loops through the (possibly shortened) list and does the deferred shading logic for up to 8 lights at once. Edited by Hodgman
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0