Tag Archives: cpp

Devil’s Canyon 4790k Benchmark

Happy New Year!

I’ve had the same desktop hardware for over 5~ years. I recently upgraded my motherboard and CPU, redid the whole build. Pictures will come soon once I tidy things up. But for now, lets see the 4790k benchmark and tests perform! Also, overclocking goodness.

Was it worth the $350?

Continue reading

Rubiks Cube AI Part 1 – Parity

Rubiks Cubes! I cant solve them to completetion for the life of me. But now I can just solve them using an AI.

But before jumping into heuristics, A* algorithms, and all kinds of solving. First, let us consider a random Rubiks Cube itself. Is the cube actually solveable in the first place? Can we go from the random state pictured above to a solved cube?

The answer is no. The Rubiks Cube parity has been altered!

Continue reading

Recommended Viewing: Ubisoft CppCon 2014

Checkout these two great talks from Ubisoft @ CppCon 2014 featuring multicore C++11 development and how C++ is used to develop AAA games at Ubisoft. I briefly met Nicolas Fleury and learned many tips from blurbs he’s written about good C++ practices and such. He’s very talented.

 

 

Programming a Boggle Algorithm

Recently had to figure out how to program a Boggle algorithm. Boggle is a simple board game I never had the pleasure of playing by itself, but have played plenty of related variations of. These kinds of algorithms are pretty interesting and I had a lot of fun programming different solutions. I’ll share 2 solutions.

Boggle is relatively simple. I never had the pleasure of playing by itself, but have played plenty of related variations of.

You have a square game board with dice of various letters that is n x n. The board gets shaken/randomized and a timer starts. The player scores points by finding valid words on the board that are longer than 3 characters, with longer words scoring more points. The rules are that letters have to be adjacent or diagonal to the last letter in the word to continue. And you can never repeat a letter you’ve already used, so while you can have multiple of the same letter, its the die itself you can’t return to.

I decided to tackle it in C++.

Continue reading

Recommended Reading: RunTime C++ Scripting

Interesting bit came up at work with our bi-weekly “brown bag” lunches with our programming team – Scripting vs Native C++ code. A lot of game developers, and even in many other realms, some of the code base may be split into Lua or Python for easy, quick iteration. I know many studios, such as many of the Call of Duty studios, use primarily Lua for their gameplay scripts.

The argument is that is easy to write, iterate fast, and provide to employees who don’t have deep programming knowledge (like some gameplay designers and such). It’s perfectly legitimate too, there isn’t anything inherently wrong with the scripting languages augmenting a huge C++ code-base engine. However, there are caveats such as managing two different languages and creating wrappers for stuff. Also, Lua doesn’t have proper debugging tools many C++ programmers are used to, and when tied into that code-base, it can become a nightmare to debug.

Enter C++ code thats runtime-compiled and used as a scripting language.

Fantastic read, pretty classy too. Each script is a single cpp file that gets compiled into a dynamic library which recompiles everytime the file changes, even during gameplay. The scripts even get a nice little compression size reduction too. Good read.

Book Review: Effective C++

Effective C++ by Scott Meyers has been around for awhile and it is pretty revered. With good reason. It is one of the books a lot of C++ programmers, both beginners and adept, read and then never look back after. After being recommended the book several times, I finally got around to picking it up.

Unlike a lot of other programming books, such as the ones I’ve previously reviewed, this isn’t a tutorial or “how-to” C++ book. So there is some technical requirement for the book and if you don’t have interest in C++, it probably won’t do much for you. But if you want to check it out, my review can be found after the break.

Continue reading

Today I Learned: Struct Packing With A Microsoft Twist

Member declaration order for structs and classes are important. You want to order the smallest to the largest (or vice versa) in order to avoid what’s known as ‘padding’. Padding is basically what the compiler will use to keep the memory allocation of the struct/class aligned in memory. This padding tends to be wasted space unless some compiler specific enhancement is occurring.

What I learned today was that Microsoft’s C++ compiler actually has extra padding involved, by design. And the solution to avoid the extra previous memory being stolen from you? Quite elementary, how could you not know? Inheriting from an empty abstract class makes your objects smaller.

Continue reading

Today I Learned: Never Rely On Memory – Let The Code Do It For You [If You Can]

So this is something I’ve seen two large camps pitted against each other for. Programmers should always be responsible for the code they write and should always be actively trying to write responsible code in itself. I think everyone can get behind that without much quarrel. But! One camp tends to argue that the programmer should ensure there is ~absolutely~ no way for things to blow up while the other camp argues that the programmer should place ‘checks’ in the code in the possibility that it does.

Hopefully the issue is clear.

Should a programmer place checks in their code to not only protect users in the future, but also themselves? “Why wouldn’t you?” your reaction may be. Well, you might have a complex piece of code that would take a lot of resources to constantly check will work properly. The goal is to make sure your code is exception-safe as much as possible, but there is always someone out there who will holler out “at what cost?!” If something is expected to work one way, that should be the ~only~ way it will ever work they argue!

It boils down to a kind of elite purist paradigm vs a human-error safe paradigm. Both have merit!

I made a pretty timely and amateur mistake today because I was running the purist paradigm. I’ll talk about how I should have placed checks to save myself and evidently my boss about 2 hours of time. But at the same time the issue could’ve been easily avoided and no check at all would’ve been needed if I didn’t rely on my faulty memory.

Continue reading

Book Review: CryENGINE Game Programming with C++, C#, and Lua

CryENGINE is the popular and insanely powerful game engine used in games such as Crysis, Ryse, and originated with Far Cry 1. Developed by Crytek,  it supports the latest and greatest visual renderers such as DX11. CryENGINE 4 is coming soon as well as Linux support. A modified version of the CryENGINE spawned the Dunia Engine, which is used by Ubisoft Montreal for Fary Cry 2 and 3.

I wanted to try my hand at playing around with the famous engine and thus I am reviewing  CryENGINE GameProgramming with C++, C#, and Lua by Filip Lundgren and Ruan Pearce-Authers, published by Packt Publishing. Read on to see how it went.

Continue reading

CryENGINE GamePrograming with C++, C#, and Lua Review Incoming

Hey everyone,

Soon I will have a review up for CryENGINE GameProgramming with C++, C#, and Lua by Filip Lundgren and Ruan Pearce-Authers, published by Packt Publishing.

It will be reviewed in the same style as the Unity Multiplayer Games review, and maybe I’ll make this a regular thing to review books I’m given or happen to pick up! Expect the review up this weekend or so.

Sample Chapters