A packing problem
From: gkhan (oskarsigvardsson_at_gmail.com)
Date: 02/23/05
- Next message: Bill Godfrey: "Re: A packing problem"
- Previous message: Randy Howard: "Re: Non-restoring binary square root and convergence"
- Next in thread: Bill Godfrey: "Re: A packing problem"
- Reply: Bill Godfrey: "Re: A packing problem"
- Reply: Stephen Brooker: "Re: A packing problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 23 Feb 2005 03:09:31 -0800
A friend showed me the game Diablo 2 a while ago, and while he was more
interested in slaying zombies I started to ponder an algorithmic
problem that the game poses. In the game you have a sort of "knapsack"
which is basically a two-dimensional grid where you could put your
items. The items had certain dimensions that could be packed in this
knapsack where no two items could overlap. For instance say that the
knapsack is 3 times 4 spaces (btw, I apologise for the crappy
ascii-art, I hope it renders correctly)
-----------
| | | | |
| | | | |
| | | | |
-----------
Then we for instance can put in a 3 times 1 sword (SW) as such
-----------
| |SW| | |
| |SW| | |
| |SW| | |
-----------
Then we want to pack a 1 times 3 spear (SP), but it does not fit.
However if we move the sword it does.
-----------
|SW| | | |
|SW|SP|SP|SP|
|SW| | | |
-----------
But now my 2 times 1 dagger doesn't fit! Well, actually....
-----------
|SW|SP|SP|SP|
|SW| |DA| |
|SW| |DA| |
-----------
This example is ofcourse trivial, but it serves to demonstrate the
general problem. Given a x times y knapsack and k items with dimensions
x_n times y_n can you fit them all into the knapsack (obviously the sum
of the areas of the itmes is less than the area of the knapsack)? I've
tried to figure out a nice algorithm for this and I've come up blank.
Is there one already? If not, has anyone got any tips? My first idea
was some sort of optimum-substructure variation using dynamic
programming or a greedy strategy, but that didn't pan out (maybe it
does and I just missed it though). Maybe some sort of adaptation of
graphing algorithms (no I am just brainstorming), an adaptation of DFS
perhaps?
Oskar
PS. My intrest in this problem is pure curiosity, it's not homework or
anything.
- Next message: Bill Godfrey: "Re: A packing problem"
- Previous message: Randy Howard: "Re: Non-restoring binary square root and convergence"
- Next in thread: Bill Godfrey: "Re: A packing problem"
- Reply: Bill Godfrey: "Re: A packing problem"
- Reply: Stephen Brooker: "Re: A packing problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|