• 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
noatom

Simple c++ problem question

3 posts in this topic

You have a large rectangle paper sheet of size W x H. You need to cut Wix Hisized pieces from this
rectangular sheet. The problem is that the paper sheet has a special coating and it can only be cut 
with a special method.
 
To cut the paper, first you have to fold it in two pieces, and then cut through the whole length of the 
fold to produce 2 smaller rectangular pieces. Thus, each cut must span the whole length of the 
rectangular piece. You will repeat this fold & cut operation on the smaller pieces until you produce 
all the required rectangular pieces.
 
The paper's coating also has a special pattern on it which prevents rotating of the cut pieces. This 
prevents cutting a Hix Wipiece instead of a Wix Hipiece.
 
Input
The input file will contain the dimensions of the paper (W, H), number of piece types (N), and the 
size of the piece types (Wi, Hi).
First line will contain W and H.
Second line will contain N.
The following N lines will contain Wi and Hi.
 
Output
The output file will only contain N+1 lines. The first line will contain a single integer number – the 
minimum amount of paper wasted. The next N lines will contain the number of pieces that will be 
cut, for each piece type.
 
Example:
 
Input:
42 22 
12 4 
14 10 
20 8 
30 20 
 
output:
 
40
3
3
2
0
 
 
My question:
 
The problem is the example.
 
If I have a rectangle of size 42 x 22 as above.And I want to cut it in pieces of 30 x 20.In the above example,it shows me that the pieces I will get will be 0.How is that possible? Shouldn't it be 1?!
 
0

Share this post


Link to post
Share on other sites

My guess would be that the aim is to minimize the paper wastage, and to do that in the example case it's not helpful to use the 30x20 sized piece (because that would leave a 22x2=44 sized piece left over, after filling the remaining space with 12x4 pieces).

 

That is:

(12x4x3) + (14x10x3) + (20x8x2) = 884

(42x22)-884 = 40 (the total paper wastage)

1

Share this post


Link to post
Share on other sites
I wrote a crude dynamic programming -based brute force solution since I haven't had the chance to use DP before. It can deal with this input, which results in 2.1M pieces, in 10 seconds on an old laptop:

10000 10000
4
12 4
14 10
20 8
30 20

but jumping up to a 15000^2 problem (result 4.7M pieces) takes minutes, I presume because physical memory runs out. I'm kind of itching to try packing the memory. Instead of piece counts and minimum cost, I could memoize only the cost and the index of the "top-level" piece of an optimal configuration for huge memory savings. It shouldn't be hugely expensive to recurse through the configurations at the end to do a final count.
0

Share this post


Link to post
Share on other sites

If I have a rectangle of size 42 x 22 as above.And I want to cut it in pieces of 30 x 20.In the above example,it shows me that the pieces I will get will be 0.How is that possible? Shouldn't it be 1?!

To expand on what Adam_42 said, it sounds like the textbook is asking you to come up with a certain number of cuts of each size such that the minimum amount of paper is wasted.

 

To give an analogous problem: I have a $3.50. There are 4 things in the store I can buy, all of them costing different prices. Let's say item 1 is $0.50, item 2 is $1, item 3 is $2, and item 4 is $3.25. What should I buy such that I have the least amount of money left? Sure, I could afford to buy one of item #4. But that would leave me with $0.25 remaining, which isn't the "least amount of money left" (because if I instead bought one of items 1, 2, and 3, I would spend $3.50 total and have 0 left, which is more "optimal").

 

Similarly, in your problem, it's not about "what can you cut?" It's about "what should you cut to get the least waste?"

1

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