Monday, October 12, 2015

PCG Introductory Material

Before we start getting into actual procedurally generated content I need to cover some basics.

All code posted will assume that you have an understanding of programming and the language. I plan on doing much of the code in C++ but this is subject to change based on what I am doing that week. If you do not know the language it should be relatively easy to follow along with an understanding of other languages.

Let's talk about randomness. Nothing is actually random. When I say random what I really mean is pseudo-random. Pseudo-random is when something appears to be random but is actually not. Because computers cannot make decisions they instead rely on algorithms to generate numbers that appear to be random but are actually not and over enough iterations would repeat and a pattern would be noticed. This pattern is so large though that humans will not notice it. For the purposes of this blog we do not actually need real randoms and pseudo-randomness will work perfectly.

When we want to create something random we rely on a seed. If two computers running the same program that rely on random numbers are given the same seed, they will generate the same output. This mean that if you at home run the code you will not necessarily have the exact same output as me. Take the code below for example.

We can see that this is an extremely basic C++ program. We have our main method and in it we create a variable called seed that we get from time. This means that when the program is run we will always print out a different value from rand because we have a different seed.

This covers some of the basic material you will need to know. I will do my best to try and explain the important and confusing parts of the code in detail as well as the general ideas being presented. However, if questions are still pertinent just leave a comment and I will do my best to explain in more detail.  I also do not claim by any means to be a C++ expert so while there are other ways and probably even better ways to accomplish the same task, I am merely presenting A way to do it, not the best.

The first real post will be coming later in the week.

No comments:

Post a Comment