Posts RSS Comments RSS Digg Technorati Blinklist Furl reddit 105 Posts and 7 Comments till now
This wordpress theme is downloaded from wordpress themes website.

Archive for February, 2016 (2016/02)

Rolling Dice

Because I chose an authentic look to the game, the game pieces do not animate and they do not require physics.  However, the dice use physics.  This allows me to do some work with UE4 that involves probability and physics… and lots of fun 🙂

When a die is done rolling, the result must be detected based on the rotation.  To double-check that I got this part correct, I wrote some code to help me visualize all possible results in terms of (pitch, yaw, roll).  I made a grid of dice with [pitch, yaw, roll] = [0, 90, 180, 270].  That’s 4 * 4 * 4 = 64 dice.  Next I made each die in the grid rotate such that the rotation does not affect the result.  For example, 2’s (pitch, yaw, roll) is (90, 0 to 360, 0 to 360) (when pitch is 90, yaw and roll are in gimbal lock).

Dice rolling happens on the actual game board, so dice can bounce off game pieces (but game pieces are not knocked over by dice).  To keep dice from falling off the board’s edges, I added invisible walls.  To keep dice from falling through the board, I enabled CCD (continuous collision detection).  Dice can land anywhere (eg on top of each other, on top of game pieces) as long as they land flat.  If a die lands at a non-orthogonal angle (no result detected), then the die bounces until a result is detected.

For the die mesh, I use a cube collision mesh with the origin in the center.  A cube has 24 rotational symmetries, 9 planes of symmetry, and 15 reflection symmetries.  Rounded corners still allow uniformly random results as long as they are rounded the same (ie maintain the symmetries).

To randomize the dice, I randomize initial state – height, rotation, impulse, torque.  For the initial rotation, uniformly sampling each of three Euler angles (pitch, yaw, roll) with a uniform distribution of 0 to 360 degrees does not result in a uniformly distributed rotation – aka a uniform sampling of SO(3).  There exist algorithms to achieve uniform random rotation in SO(3).  A simpler method for dice is to pick from a small number of initial rotations such that the physics engine will give uniformly random results.

To achieve this, I use 6 possible numbers on top * 4 right-angle rotations = 24 possible initial rotations.  This gives us a uniformly random initial state, so anything we do (or use the physics engine to do) after that will be uniformly random as long as it’s changes to dice rotation are independent of this initial uniformly random state.  To add realism and variation, I then do another non-uniform random rotation.  Dice in the grid are spaced by cube diagonal length plus a small offset.

For the initial state, dice are grouped together in a 3D grid (1x1x1, 2x2x2, or 3x3x3).  Each die in the group has the same initial impulse (velocity).  In some cases, a die (or dice) in the group has stopped moving, but then another die can bump it.  Because of this, I do (wait for done moving) and (bouncing for non-flat dice) per group rather than per die.  Ie I wait for all dice in the group to stop moving, and if any dice land flat, then non-flat dice bounce until all dice in the group land flat.

The official game only comes with 2 movement dice and 6 combat dice.  Under normal circumstances, you would roll (2 movement dice) or (5 or less combat dice)…  The only way you’d roll more than 6 dice is if you have something like a 4 attack battle axe + 2 attack courage spell + 2 attack potion of strength.  But just for fun, I’ve included a screenshot of a movement dice pile, and a screen shot of a 200 dice roll.  I’ve also posted a video showing some die rolls in action – 2 movement dice, 3 combat dice, a 100 die stress test, and a 255 die stress test.

image image image image image image image image image

Vulkan 1.0 released

I started writing DirectX/OpenGL code when I took multiple college classes in computer graphics and game programming (in 2001 or 2002).  In the years since then, I’ve continuously been exposed to DirectX/OpenGL through my GPU modeling job and through hobby projects.

So I have experience writing code for different versions of DirectX/OpenGL APIs and seeing their evolution.  In the time of my experience, there’s been some major API changes such as the move from fixed function pipeline to programmable pipeline (shader programs) (GLSL, HLSL).

Yesterday was another big change – Vulkan 1.0 was officially released.  Vulkan is lower level (like Microsoft DirectX 12 and Apple Metal), but it’s also cross-platform and cross-vendor.  I’m really into my Unreal Engine 4 project for the time being (and probably all of 2016), but I at least did some reading about Vulkan.  Here are a few links I enjoyed reading to get a taste of Vulkan:


API reference:

Detailed Overview:

Samples – Hello World Triangle


HeroQuest – Prior Work and References

HeroQuest (Games Workshop, Milton Bradley) was released in America and Canada in 1990 (Europe and Australasia in 1989). Today there are some great HeroQuest fan websites and online communities. In the 26 years since the American release, there have been software development projects related to HeroQuest including video games and map editors. This post is an overview of prior work and references in the HeroQuest community that relate to my project.

Board Game: The original board game has long been out of print. The American release and the European/Australasian release have minor differences.  The six standard expansions are – Kellar’s Keep, Return of the Witch Lord, Against the Ogre Horde (Europe only), Wizards of Morcar (Europe only), The Dark Company (Europe only), The Mage of the Mirror (America only), The Frozen Horror (America only).  Related games were released by Games Workshop including Advanced HeroQuest and Warhammer Quest. An unofficial 25th anniversary edition was crowdfunded.  Fan websites have variations on everything – quests, boards, tiles, rules, heroes, monsters, cards, etc.

  Image result for kellar's keep Image result for return of the witch lord Image result for against the ogre horde Image result for wizards of morcar Image result for heroquest advanced quest dark company Image result for heroquest mage of the mirror Image result for barbarian quest heroquest

Rules: There are some ambiguities in the details of the official HeroQuest rules.  I’m focusing on the American rulebook, but I’m also using the European rulebook as a reference.  I’ll eventually want to include the European expansions, and this merging will require some interpretation.  Online websites and message boards are another way to "research" interpretations of these nuances.

image image image

Art: Some of these websites have great 2D scans of cards, rules manuals, quest books, tiles, the board, the armory, the cardboard parts of furniture, and photos of the figures.  Two great links are ( , ).  Very little exists in terms of 3D models of the plastic miniatures and furniture – the heroes, the monsters, and the plastic parts of the furniture.

Map Editors: HeroScribe seems to be the golden standard. The quest maps look authentic and use vector graphics. The file format is simple XML.  XML files are posted for all official quest books.  It runs on Linux Mac Windows (Java). The news section says it’s been around since 2002/06/19, the latest post is 2014/12/03, and HeroScribe is referenced by major HeroQuest fan websites.  One limitation is that HeroScribe is only for the map part of the quest.  In theory it makes sense to add quest text to the editor and the XML, but it’s a hobby project so I can understand why the HeroScribe author(s) decided to focus on the map.


Quest Text Editors: The other part of a HeroQuest quest is the text.  In 2012, “Patroclus” posted bare bones "HQ Quest Maker" to that allows you to edit quest text then save a png and a simple ini file.  The ini file is great for sharing, further edits, or use by other software (unfortunately ini files for the official quests are not posted).  It’s a one-off binary release posted to a message board.  It’s simple and effective.  Unfortunately, it’s easy to make the program crash or give weird output.  I see no updates since the original post (2012 Sep), and it’s not open source.


Other Software & Websites: I’ll just mention there are some great HeroQuest fan websites (forums, videos) – many of which have new HeroQuest content and/or tools to create new HeroQuest content.  My focus (at least for 2016) is to create a video game based on the official releases – with a strong focus on the nostalgia of authenticity.

HQGM by Keld Hjortskov 2002-2003: : According to whatsnew.htm, the first beta release was 2002/01/31, and the last release was 2003/11/30.  This is not a standalone game.  Rather, it’s a software tool that you can use use with the physical board game to run Zargon (the DM) without having a player dedicated to it, and without having a player look at the full quest map.

The software handles the following – visibility (revealing rooms, line of sight), AI movement of monsters, AI actions of monsters, and monster attack/defense rolls.  It’s designed to use with the physical board game, so when you do a move or roll attack dice, you enter the result of the roll into the software.


Video Games: I’m not the first to create a HeroQuest video game, so I’ll give some examples of prior work.

Official Game by Gremlin Interactive 1991: The game was released for PC (DOS).  There’s a map view, but most of the action takes place zoomed in on the current hero’s room/hallway, which I find awkward.  Attacks switch to a special combat screen, which I find awkward.  There was an NES port under development that never got officially released.  It was also released on other platforms (Amiga, Amstrad CPC, Atari ST, Commodore 64, ZX Spectrum) with different graphics.

    Image result for heroquest game NES HeroQuest Amstrad CPC Starting the Maze. HeroQuest Commodore 64 First Quest: The Maze HeroQuest Commodore 64 Select A Quest HeroQuest ZX Spectrum On the move

HeroQuest Isometric PC Game by LurchBrick: : Latest update 2007/10/23.  Original quest book, Kellar’s Keep, Return of the Witchlord.  Prior to the isometric version, LurchBrick also wrote a top-down version that he describes as – “my first attempt at making a game so it has some bugs”.

 Isometric HeroQuest screenshot 3 

HeroQuest PC Game by Gerwin Broers: : The page says "Copyright 2003-2009" and the latest release is labeled 2012-07-11.  This one gives a full view of the game board as top-down 2D tiles.  It has the standard game, and also options to customize it.  I tried it out, and overall it seems more robust than Lurchbrick’s isometric game.

HeroQuest Java beta version by Rob Vitaro: : beta hobby project released 2009/03.  I tried it out, and overall it appears to have a lot of functionality.  There’s a robust set of game menus and GUI interactions.  Unfortunately, besides arrow keys for movement (or WASD) (and O to open doors), the GUI is almost entirely mouse driven – so I found it awkward and inefficient.  Way too much mouse clicking of GUI buttons.  Some players may like the WASD + mouse input, plus it’s easy to learn, but having an option for power users with more use of the keyboard would be more efficient.  Other than that it looks promising.  Lots of functionality – spells, equipment, etc.


HeroQuest module for Vassal by LurchBrick: : LurchBrick’s third attempt at a HeroQuest game was to make a module for VASSAL.  VASSAL is a game engine for building and playing online adaptations of board games and card games.

image 2hhq-the-quest-begins 

3D prototype by dabein on : I found four screen shots on of a 3D prototype by dabein (Bob Sawyer).  The screen shots look similar to what I’m creating – in fact his 2008/04 post says "I am trying to make the game as authentic as possible".  The first post is dated 2007/11.  His 2009/10/13 post says "I dont think I’m ever going to finish this".  His 2011/06/28 post says "It’s not abandoned yet", but he has no activity on since then.

First Heroquest Screen by dabein Second Heroquest Screen by dabein Heroquest Screen 3 by dabein Heroquest Screen 4 by dabein

Official Warhammer Quest by Rodeo Games 2012-2015: In 2013 Games Workshop released an official Warhammer Quest game for iOS, which was later ported to PC, Mac, Linux, and Android.  It’s not HeroQuest, but it was the successor to HeroQuest.


Tabletop Simulator 2014-2015+:
An amazing project that allows players to play tabletop games in a player-driven physics sandbox (created with Unity).  I almost started down a similar path, and at first glance Tabletop Simulator looks similar to my project.
But Tabletop Simulator is a generic interface to any tabletop game.  It has lots of good generic functionality that maps well to HeroQuest – rolling dice, interacting with cards and decks, snapping game pieces to a grid, health counters, notepads.  It’s a well-polished small indie commercial project.
HeroQuest support is an add-on (a mod) achieved as the wiki describes via "create your own games by importing images onto custom boards & tables, create custom decks, import 3D models, and much more".  Game logic is controlled by the players (not the software).
So Tabletop Simulator lacks any HeroQuest-specific game logic, menus, interfaces, AI, etc.
In some ways it’s a “feature” that Tabletop Simulator does not have HeroQuest-specific code, because part of the fun is that it’s like a real board game in that the players control the pieces, execute the game logic, and if the players want they can tweak the rules (or even just throw pieces around instead of actually playing HeroQuest – obviously this is a double-edged sword).  In the case of HeroQuest, interpretation is required because there is ambiguity in some of the rules.
One of my first thoughts when looking at Tabletop Simulator was that it could theoretically implement a plugin system to allow third party developers to implement game-specific functionality, and then someone (such as me!) would implement code for HeroQuest-specific UI, game logic, Zargon AI mode, etc.
As I write this post, Tabletop Simulator actually does have some form of beta scripting support using Lua.  I haven’t looked into it much yet, but it might be an interesting project to implement a HeroQuest mod for Tabletop Simulator.  It might be interesting to check out Tabletop Simulator’s Lua scripting support at some point.  For now I’m excited about continuing my Unreal Engine based implementation of HeroQuest.
  image image  

HeroQuest map loader

It’s only been a week since my first Unreal Engine category post, but I have an exciting screen shot for this post.  I’m creating a video game based on the classic board game HeroQuest (released in America in 1990) (Games Workshop and Milton Bradley).

I made programmer art (placeholder art) (static meshes) based on photos of the board game’s plastic figures and scans of the printed cardboard.  I did some editing in Blender and some hand-editing of the *.obj (and *.mtl) text files, which I then imported into Unreal Engine.

I handwrote a simple text file for the first quest (Quest 1: The Trial) by looking at the quest book.  The map format is just a list of “occupants” that occupy (a) specified game board’s 26×19 square(s).

In Unreal Engine, I wrote C++ code to load the quest map file into game logic, and then to spawn actors based on the game logic representation.

Here’s a screen shot of Quest 1 loaded, and a scan of Quest 1 from the quest book.

image image