Using dynamic programming to break down a complex problem
Dynamic programming is a very modern way to solve problems. The process involves breaking a big problem into smaller chunks of problems, finding solutions for those chunks and repeating the process to solve the entire complex problem. It is a bit difficult to grasp this technique at first, but with sufficient practice any problem can be solved using dynamic programming. Most of the problems we will encounter while programming a video game will be complex. Hence, mastering this technique will be really useful.
Getting ready
For this recipe, you will need a Windows machine with a working copy of Visual Studio.
How to do it…
In this recipe, we will find out how easy it is to use dynamic programming to solve a problem:
Open Visual Studio.
Create a new C++ project.
Select Win32 Console Application.
Add a source file called
Source.cpp
.Add the following lines of code to it:
#include<iostream> #include <conio.h> using namespace std; ...