Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Procedural Content Generation for Unity Game Development
Procedural Content Generation for Unity Game Development

Procedural Content Generation for Unity Game Development: Harness the power of procedural content generation to design unique games with Unity

eBook
€22.99 €32.99
Paperback
€41.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Table of content icon View table of contents Preview book icon Preview Book

Procedural Content Generation for Unity Game Development

Chapter 1. Pseudo Random Numbers

This chapter will introduce the idea of procedural content generation and one highly useful component, pseudo random numbers. Later in the chapter, you will use pseudo random numbers to create a derivation of the classic Hello World program. For convenience, procedural content generation will be abbreviated to PCG for the remainder of the text. Let's also abbreviate pseudo random numbers to PRNs.

Here's a quick overview of what the chapter will cover and what you will learn:

  • Define PCG: What it is and what you can do with it
  • Discover PRN generation
  • Learn how PRNs relate to PCG
  • Use PRNs in our first program
  • Develop a new randomized PCG like the Hello World program

In this chapter, we will complete a very simple step-by-step example. The example in this chapter will be simple enough to help introduce newcomers to Unity and also serve as a refresher to those coming back after some time away. However, it is important to remember that the successive examples will be much more involved. It is best that you are fundamentally familiar with Unity and C# scripting in Unity.

Note

Unity Technologies offers a range of tutorials for beginners at https://unity3d.com/learn/tutorials.

You can also reference the Unity Documentation if you need to know the usage of any specific part of Unity at http://docs.unity3d.com/Manual/index.html.

Now, let's dive in and start learning.

Introducing PCG

We begin our learning adventure with the broad concept of PCG. The key word here is procedural. A procedure in programming, simply put, is an instruction to be executed. Procedures are the main paradigm in computer programming. A script you write in Unity is just a set of instructions or procedures we want Unity to perform.

You use procedures, methods, or functions as a means to communicate the instructions you want the computer to complete. We can use these same procedures to instruct the computer to generate content in many different ways. We can apply this idea to a broad range of programming disciplines such as data visualization, dynamic advertising, and so on, but in this book, we are using it for video games.

If procedural is the how then content is the what. Content can be anything we are presenting to the user. In our Hello World example later in the chapter, our content will simply be text. However, video games have a wide range of assets that make up the content we want to deliver to a player.

Typically, we think of the levels, character models, and other art assets when we think of content in video games. But there is also textures, music, sounds, story, artificial intelligence, and more that together make up the content of a game. PCG is the concept or paradigm by which all these pieces of content can be generated with some well-written code. PCG can be applied to nearly all aspects of a game through scripting, and you will learn some of the main ways to do this throughout the book.

Introducing PCG

On the left is a hand-drawn texture, and on the right is a Procedurally Generated texture

What's exciting about PCG is that we can let the computer take some of the responsibilities of the designer by giving it some instructions and letting it create parts of the game world on its own. We might even be surprised by the results. As developers, we usually do not like being surprised by our script's actions, but in this case, it's part of the plan.

PCG can also come in a few different forms for practical use. We can generate content from scratch, such as the texture see earlier, or we can generate assets from a set of premade parts, such as generating a tavern scene from premade props such as tables, chairs, barrels, and crates. Another option, though, is providing tools to the player to take on the role of creating content. The player creating content isn't necessarily PCG but you will have created a PCG system that now takes user input as a parameter. A great example of this is the popular game Minecraft developed by Mojang.

Introducing PCG

A player-created building in the popular game Minecraft

Minecraft is also an example of one of the most popular uses of PCG, randomization. Players in Minecraft can make structures and break down the land around them. However, the game's entire landscape is based on randomization. Randomization is used in many games, both virtual and table top. Randomness introduces a chance factor that creates fun out of unpredictability.

However, the most important thing about randomness in video games is that it is almost impossible to achieve true randomness on a computer system. This is why we refer to them as pseudo random numbers, because they are technically not random. We will explore this aspect of randomness, or pseudo randomness, later in the chapter with PRNs.

Usage of PCG

The reasons we might consider using PCG include unique, robustness, adaptability, and size. We might strive for our player to experience the game in their own truly unique play-through. We could use PCG to take the content that we have designed and make truly robust games that would take many hours to explore every inch of. We can make our game adapt to the player in interesting ways such as scaling the difficulty to easier or harder based on the actions of the player.

Size, though, is an interesting benefit to PCG. Well before games played with amazing HD graphics at 60 frames a second, they were mostly text based. Early computer systems were very limited both in processing power and storage memory. One of the earliest occurrences of PCG was in games that procedurally generated levels using ASCII characters. We can see an example of this in the game Rogue developed in the 1980s. We discuss Rogue and the subsequent sub-genre of games Roguelike in later chapters.

PCG was thus a solution, of sorts, to the fact that early computers really had no means to present graphics to the player. Graphics comprise the bulk of a game in terms of size taking a lot of processing power and memory. The procedurally generated ASCII levels of Rogue were calculated instead of being loaded from the file. This meant early computer systems could use memory and processing power as needed instead of needing a lot of memory all at once when you start a predefined game level.

We can also consider size savings in terms of our team as well. A designer/artist typically will need to make every piece of game content by hand. As games get larger, it becomes more difficult to create enough unique content within one game. Games lose their reward factor and players become bored easily when they see continuous repetition of in-game content. We then need to produce more content, which means more designers, artists, and individual assets. PCG helps alleviate this need by taking on some of the burden of producing unique content.

PCG can thus be viewed as a tool for the designer. There is a very creative facet to the idea of PCG. We can design pieces or modules of a whole, like a level or item, and use PCG to put them together in unique and interesting ways. We could also make 3D models, but then, we would have to generate the textures for them. Otherwise, we could generate full levels from scratch and add in some designed props. There are plenty of possibilities to fit the situation or team's needs.

Usage of PCG

Some of Gearbox Software's Borderlands procedurally generated weapons, each generated from asset modules

You also have a unique opportunity to create games that can expand infinitely (or close to it). We will see this later in the book when we learn how PCG can be used to create a game level that never ends. Are you convinced that PCG is an amazing game development component?

Application of PCG

Where we can apply PCG is an interesting question, as it can theoretically be applied to every aspect of a game. Here is a brief list of examples of where it has already been used:

  • Level layout—Blizzard Entertainment's Diablo series
  • Unique item creation—Gearbox Software's Borderlands series
  • AI behavior—Hisanori Hiraoka, Daisuke Watanabe, and Kyohei Fujita's dreeps
  • Texture generation—Farbrausch's .kkrieger
  • Model Generation—Speed Tree (which can be used with Unity)
  • Storyline—Bethesda's The Elder Scrolls 5: Skyrim Radiant Quests system
  • Music—Ed Key and David Kanaga's Proteus

This list encapsulates some of the more popular uses of PCG. As a game lover, you are encouraged to research each of these games as they are wonderful examples of PCG. We will cover most of these topics in this book, but this is by no means an exhaustive list of how PCG can be used in game development.

So now you know what PCG is but what about implementing it? To put it plainly, PCG is just the idea that we can automatically generate game content. We will develop different algorithms and use certain programming practices to apply the idea of PCG to our video games.

One of the more popular ways to implement PCG utilizes randomness or random events to produce content. It is popular because it is easier to let randomness determine certain events over scripting every outcome. For example, we might let randomness determine which pieces are used to generate the weapons seen previously in Gearbox's Borderlands. We might use a pseudo random number generator and bind each piece of the weapon to a randomly determined number. Of course, keep in mind that this isn't truly random as we will soon discuss further.

Pseudo random numbers

Random numbers have been used in games for a very long time, from traditional card games to dice rolling in table-top games. Random numbers add a chance factor to games that make them exciting and forever unpredictable. The unpredictability of a game is exciting because it always offers a unique experience. You can introduce this randomness factor into your games with a little computer science in the form of a PRN generator.

PRNs and PRN generators are a highly researched subject in computer science, as they are central to cryptography and cyber security. If you ever look into cryptography, you'll find it heavily steeped in complicated mathematics. Luckily, Unity has a very easy method to generate random numbers. Certainly, the complexity of secure number generation isn't required for video games. Nonetheless, it is important to understand some of the theories behind what seems like magic.

Random versus pseudo random numbers

The most important distinction to make is that PRNs are not random numbers. A truly random event would be something like a die roll. We could write some sort of physics simulation to simulate a die roll to achieve a random number. We could also take the static from a TV screen and plot it on an XY plane and take a single point to represent a random number. However, PRNs are preferred in game programming because they are easier to generate. The preceding examples would take too much processing power as they are a fairly complex idea. But a PRN generator is an equation that calculates a string of numbers. This also produces an added benefit of being able to find our way back to a certain generated result.

You could generate a more random sequence of numbers by grabbing points off our TV static graph, but what if you want to reproduce a result? Imagine we created an entire planet using a specific sequence of random numbers. Unless we generate that planet the first time, record the sequence used, and ship the game with the sequence included in the code, we might never be able to reproduce those results again.

Now imagine we generated trillions of planets. We would have to somehow come up with a system to store all the results of generating each planet on the first run. That just sounds unwieldy. A PRN generator, however, uses a seed number to generate a sequence, which will eventually repeat. So, instead of saving all the information needed to generate the planets, we just need the PRN generator equation and seed to regenerate all the planets at runtime.

Random versus pseudo random numbers

Random number noise signals – on the left is a random number pattern that does not repeat and on the right is a PRN pattern that repeats

A seed in reference to PRNs, is simply a number either designated by you or by some other pseudo random means. The Unity Random method will acquire a seed from the system time if you don't provide one. The seed of a PRN generator can be stored as a variable like you would store any number in a script. This is useful when we need to recreate the sequence. We just plug our seed back into our number generator and get the same sequence again.

For example, imagine we used a sequence of PRNs to create a level. Let's say the numbers represent whether a room, a hallway, or a trap is placed in a certain area. Now, a player has just finished that level and we decide to delete the level to save space in the memory. But later, the player gets a quest that requires them to go back to that same level. If we keep the seed number we used to generate the level, we can put the seed back into our number generator, get the original sequence, and remake the level as it was initially.

As stated earlier, one of the side effects of PRN generation is that it is cyclical. There comes a point in which the PRN generator generates the seed again, starting the process over. This is important to consider as it might become a cause of repetition in some of your procedurally generated content. There are multiple factors in avoiding repetition, such as the size of the number, the value, and the sequence range. Unity's Random method should be enough for most cases though.

So, in short, you know that PRNs are not random numbers but they are close enough. The key points are:

  • PRN generators need a seed value
  • You should store the seed value so we can easily recreate the PRN sequence
  • PRN generators will eventually repeat
  • If repetition becomes a problem, look into creating a more complex equation for a longer seed range

PRNs are cool and all, but how are they used?

PRNs in PCG

You can use PRNs as a decision driver to PCG. As a developer you want to be concerned about minimizing minor detail decisions. These decisions could be tasks such as placing every single tree by hand in a forest scene. You want the scene to look realistic but placing all of them yourself could be very time consuming. You can use PCG for some of this decision making. Using some directed randomness to build the forest for you saves a massive amount of time.

PRNs in PCG

A forest scene created with Unity Terrain Engine which uses PRNs

So it's time to get our hands on this! As previously stated, PRN generation can be a complicated mathematical problem but Unity has a built-in class for us called Random. Now, let's get exposed to PRNs in our first PCG example.

Random Hello World

We are going to start with an age-old classic programming example, the Hello World program. If you have been programming for a while, you likely have done one or more of these already. There will be a twist though. We are going to use PRNs to randomize how we say Hello World.

Note

Be aware that this book is using Unity 5.2.2. Some of the examples will be incompatible with earlier versions.

Classic Hello World

Let's begin by setting up the project and completing the classic Hello World program. Start by launching Unity and creating a new project. You can name it Hello World. You can also set the perspective to 2D since most of what we do in this book will be in 2D.

Classic Hello World

Unity launch screen

Once the project is loaded, we will create a new Text GameObject in order to render our Hello World to the screen. On the top toolbar, select GameObject | UI | Text. This will place a new Canvas object with a Text object child onto the scene. An EventSystem is also placed in the Hierarchy panel but you can ignore this.

Note

If you are unfamiliar with or would like to know more about Unity's UI features, Unity Technologies offers video lessons on the topic. You can find them at http://unity3d.com/learn/tutorials/topics/user-interface-ui.

Classic Hello World

Canvas is mostly off screen and you have to zoom out quite a lot to see the full view. Rather than zooming out, let's adjust the Canvas to occupy the Main Camera view space, as follows:

  1. Select Canvas.
  2. Select the Render Mode dropdown in the Canvas component section.
  3. Select Screen Space - Camera.
  4. This will open up a new field called Render Camera.
  5. From the Hierarchy pane, drag and drop the Main Camera object into the Render Camera field.

This will adjust your Canvas object to fit the Main Camera view. You might still need to zoom out slightly to see the edges of Canvas.

Classic Hello World

Workflow to get the Canvas in Main Camera view

You might have noticed at this point that there is some text on the screen. In the lower left corner of the Canvas, it says New Text in a default grey that is difficult to see. Let's change that.

Select the Text object, which is a child of the Canvas object. First, we will change the position. In the Rect Transform component section:

  1. Select the value in the Pos X field and change it to 0.
  2. Repeat for the Pos Y field.

The anchors are set to center so the Rect should snap to the center of the Canvas. Next, we'll change the size of the Rect so that we can make the text larger:

  1. Select the Width field and change it to 500.
  2. Select the Height field and change it to 65.

This will allow us to have much larger text. Note that if we had just tried to change the font size without changing the Rect size, the text would be clipped or would even vanish completely. Now let's get the text looking nice by going to the Text (Script) component section:

  1. Under Character, select the Font Size field and change it to 55.
  2. Under Paragraph, select the center alignment button.
  3. Select the Color field and change it to white.

    Note

    The center alignment button appears as Classic Hello World in the Unity Editor.

Now our text is nice and visible. At this point, you can select the text in the Text field and delete it. We are going to have our script write the text for us.

Classic Hello World

Finished canvas and text formatting

Let's start scripting by creating a new C# script. On the top toolbar, select Assets | Create | C# Script. This will create a new script in your Assets folder under the Project pane. You can name the script HelloWorld.cs.

Open the script in MonoDevelop or your favorite IDE. We are going to use the following Code Snip 1.1:

1 using UnityEngine;
2 using UnityEngine.UI;
3 using System.Collections;
4 
5 public class HelloWorld : MonoBehaviour {
6 
7   public Text textString;
8 
9   void Start () {
10     textString.text = "Hello World";
11  }
12 }

Tip

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Let's take a look at what's happening in Code Snip 1.1:

  • Line 2: Be sure to include UnityEngine.UI or you won't be able to access the Text component
  • Line 7: This is our public Text object, which we will define in the Unity editor
  • Line 10: At the start of the scene, we will take our text object and assign the string Hello World to it.

That's all there is to it. Now, we just need to add the script to the scene. It doesn't matter which object you attach the HelloWorld.cs script to because we will declare the specific Text object the script acts on. To keep things organized, this way works well:

  1. Drag and drop the HelloWorld.cs script from the Assets folder to the Text object on the scene.
  2. Drag and drop the Text object from the Hierarchy pane to the Text String field in the Hello World (Script) component of the Text object.

Now, you can press the play button, and you'll see Hello World in a large font:

Classic Hello World

Hello World program's result

That completes the Hello World program. However, that's not all that interesting. In order to give this classic programming example some new flair, let's add some randomness.

PCG Hello World

Using our Hello World example, we will add PRNs into the mix and give our program some procedurally generated text. We'll start by editing our current HelloWorld.cs script. The goal here is to randomly display one of a few variations of the Hello World text.

You can achieve this by creating an array of different strings and having Unity's Random method choose a number from 0 to the length of the array. You will use that PRN as the index of the string array. In this case, our array holds the Hello World string in a few different languages. So instead of telling the Text object to display Hello World, we will tell it to display the contents of the array at the PRN index.

Note

Unity's Random.Range has a usage of (inclusive, exclusive). In our code, we use Random.Range (0, 4), which means 0 will be in the selected range but the range stops at 3. One reason for this is if we have a C# list, we can write the range as (0, List.Count) instead of (0, ListCount - 1).

You can find more information on Unity's Random at http://docs.unity3d.com/ScriptReference/Random.html.

Open the HelloWorld.cs script and make the following changes in Code Snip 1.2:

5 public class HelloWorld : MonoBehaviour {
6 
7   public string[] hellos = new string[4] {
      "Hello World", "Hola Mundo", "Bonjour Le Monde", "Hallo Welt"};
8 
9   public Text textString;
10
11  void Start () {
12    Random.seed = (int)System.DateTime.Now.Ticks;
13    int randomIndex = Random.Range (0, hellos.Length);
14    textString.text = hellos[randomIndex];
15  }
16 }

The changes in Code Snip 1.2 are as follows:

  • Line 7: Here you will declare a string array that we can call hellos, which will hold all our Hello World strings.
  • Line 12: This is the PRN generator seed, which we discussed earlier in the chapter. We are picking a random number to seed the generator. The seed comes from your computer's current time in processor ticks (which is somewhere around a millisecond).
  • Line 13: Here, we call Random.Range to choose a PRN from 0 to 3, which will be the index of hellos that we choose to display.
  • Line 15: This line is a modification from our previous example; here, we set the text display to our randomly selected Hello World string.

Head back into the Unity editor to see the changes. You should see the new Hellos field. If you expand it, then you will see all of the strings contained in the array. The script might also lose connection to the Text object. You can just drag and drop the Text object into the Text String field to reconnect it.

PCG Hello World

Hello World with PRNs program result

And that's it. You completed your first PCG capable program. Test it out by pressing the play button. You will randomly get one of the four Hello World strings displayed in the Game screen. There are only four choices so you might have to try a couple of times before you start seeing any variation.

Challenge

As an added challenge, you can turn this into a die simulator. Try on your own to have the script display a random number from 1-6. You can, instead of displaying text, display an image of a die face. Also, see if you can display the image and store the random number corresponding to the die face for reference.

You can also try changing the seed to a number of your choice. If you play the scene with a constant number, you will get the same result every time. Try different numbers for different results. This is the benefit of the seed value; even though we are introducing a bit of randomness to our game, we have a way to control it. We will explore the seed value further in a later chapter.

Summary

So you learned quite a bit of theory in this chapter and just touched the surface of how to apply it to games in Unity. You went over an introduction to PCG and why and how to use it. You were also introduced to PRNs and to how they are generated. We discussed what makes PRNs different from your average random number and the benefit a seed provides. You also learned why and how to use PRNs and then completed an example expanding on the classic Hello World program.

So what's left? Well, we are gearing up to build a fully functional game throughout this book. We are going to look at some of the more popular applications of PCG in video games. In the next chapter, we are going to briefly get acquainted with Roguelike games, which is a popular game subgenre. Roguelike games are known for their procedurally generated content, so it is a perfect fit for our learning adventure.

Left arrow icon Right arrow icon

Key benefits

  • Learn the basics of PCG development
  • Develop a 2D game from start to finish
  • Explore all the different ways PCG can be applied in games

Description

Procedural Content Generation is a process by which game content is developed using computer algorithms, rather than through the manual efforts of game developers. This book teaches readers how to develop algorithms for procedural generation that they can use in their own games. These concepts are put into practice using C# and Unity is used as the game development engine. This book provides the fundamentals of learning and continued learning using PCG. You'll discover the theory of PCG and the mighty Pseudo Random Number Generator. Random numbers such as die rolls and card drafting provide the chance factor that makes games fun and supplies spontaneity. This book also takes you through the full development of a 2D game. Starting with level generation, you'll learn how PCG can make the game environment for you. You'll move into item generation and learn the different techniques to procedurally create game items. Thereafter, you'll be guided through the more abstract PCG areas such as scaling difficulty to the player and even generating music! The book helps you set up systems within your games where algorithms create computationally generated levels, art assets, quests, stories, characters, and weapons; these can substantially reduce the burden of manually creating every aspect of the game. Finally, you'll get to try out your new PCG skills on 3D terrain generation.

Who is this book for?

This book is for Unity game developers, especially those who work on indie games. You should be familiar with Unity and C# scripting but you'll be able to jump in and start learning PCG straightaway.

What you will learn

  • Understand the theory of Procedural Content Generation
  • Learn the uses of Pseudo Random Numbers
  • Create reusable algorithm designs for PCG
  • Evaluate the data structures for PCG
  • Develop smaller games with larger amounts of content
  • Generate content instead of spending time designing every minute detail
  • Learn when and how to add PCG to your game
  • Learn the fundamental techniques of PCG
Estimated delivery fee Deliver to Netherlands

Premium delivery 7 - 10 business days

€17.95
(Includes tracking information)

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Jan 30, 2016
Length: 260 pages
Edition : 1st
Language : English
ISBN-13 : 9781785287473
Vendor :
Unity Technologies
Languages :
Tools :

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Estimated delivery fee Deliver to Netherlands

Premium delivery 7 - 10 business days

€17.95
(Includes tracking information)

Product Details

Publication date : Jan 30, 2016
Length: 260 pages
Edition : 1st
Language : English
ISBN-13 : 9781785287473
Vendor :
Unity Technologies
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 120.97
Unity UI Cookbook
€41.99
Unity 5  Game Optimization
€36.99
Procedural Content Generation for Unity Game Development
€41.99
Total 120.97 Stars icon
Banner background image

Table of Contents

11 Chapters
1. Pseudo Random Numbers Chevron down icon Chevron up icon
2. Roguelike Games Chevron down icon Chevron up icon
3. Generating an Endless World Chevron down icon Chevron up icon
4. Generating Random Dungeons Chevron down icon Chevron up icon
5. Randomized Items Chevron down icon Chevron up icon
6. Generating Modular Weapons Chevron down icon Chevron up icon
7. Adaptive Difficulty Chevron down icon Chevron up icon
8. Generating Music Chevron down icon Chevron up icon
9. Generating a 3D Planet Chevron down icon Chevron up icon
10. Generating the Future Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Empty star icon Empty star icon 3
(2 Ratings)
5 star 0%
4 star 0%
3 star 100%
2 star 0%
1 star 0%
Jesse May 29, 2016
Full star icon Full star icon Full star icon Empty star icon Empty star icon 3
[Some comments in this review may be outdated. The review was originally posted on 2016-05-29.]I bought this book hoping to see some interesting PCG techniques and in-depth insights, but was mostly disappointed. The book is suitable only as a basic introduction to PCG with Unity. People who have any prior experience with PCG will generally find little of value in this book.The quality of the writing is mediocre overall. There's generally no trouble with basic comprehension of what the author is saying, but the book has numerous minor typos and sometimes poor grammar/semantics. The style of the sentences is simple to the point of feeling stilted and bland. There's a fair number of sentences that don't really mean much beyond what the reader would already be assuming anyway. Some of the code examples contain typos of variable names, which is thus proof that at least some of the code samples were never tested at all (otherwise the compiler would have caught the typos).The author makes some incorrect statements about PCG in the book. For example, on the top of page 7 he says rolling dice and simulating other kinds of physical systems would allow you to generate truly random numbers on a computer, but because doing so is computationally expensive programmers use pseudo-random numbers instead. This statement is completely false. That is not the reasoning behind pseudo random number use. A dice simulation or other physics simulation would also be just as pseudo random. The author basically just completely fabricated this statement instead of doing proper research. There are several other examples in the text of him basically doing the same thing.I get the feeling that the author himself didn't actually know much of anything about PCG prior to writing the book. That being said, it would probably be a fair into to a beginner, provided the beginner is aware that the author's work contains errors and some bad advice from time to time. The code quality is generally poor to mediocre. The author frequently mixes implementation details that have no business being put together. Several of the classes he uses are also probably superficial and could be refactored (especially the "Manager" classes). The book has either been poorly edited or was never edited at all. The authors code is not very well factored and not very modular. His advice to use inheritance on a few occasions is also misguided. Components are a superior solution when properly understood.I have read online that Packt Publishing has a reputation for "quantity over quality" publishing. I even read about a different author on a forum describing how when he submitted their book to them, the publishers actually *added* more errors into the book through their editing than they removed from it and actually made the English quality worse instead of better. Supposedly they have non-technical editors who make changes to the technical text without actually fully understanding the context and semantics. Thus, it is possible some of the mediocre writing is the publishers fault and not the author's, but this is all speculation.The PCG techniques the author chooses to use are some of the most crude and uninteresting forms of it. He basically always just uses a plain old random number to select from a set of options every iteration. You won't find any advanced PCG algorithms in this book.In summary: This book is OK if you are a beginner at PCG, provided you understand that the author's work contains some misinformation and bad programming practices. If instead you are looking for deep insights into PCG or interesting PCG techniques (like me), then you should definitely avoid this book. It has little value to anyone who already understands the basics of PCG.You should also be wary of this publisher.
Amazon Verified review Amazon
Amazon Customer Apr 05, 2016
Full star icon Full star icon Full star icon Empty star icon Empty star icon 3
Bought this book expecting to learn basics of PCG. And I wasn't disappointed. This book definitely has lots of information about content generation but is also has errors. Too many of them for the book of this size and price.For example, not all code examples in the book are working as some parts of code are missing or are being used not in the right place.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact [email protected] with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at [email protected] using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on [email protected] with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on [email protected] within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on [email protected] who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on [email protected] within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela