Are we making the dinosaurs too smart?

Traces of the artificial intelligence (AI) calculations for dinosaurs’ optimal paths to food. The AI chooses paths with least steep slopes and avoids terrain (like swamps) that would unnecessarily slow the dinosaur down. Screen capture.

Yes, I know in Jurassic Park velociraptors could open doors (I would post a picture, but I’m worried about lawsuits so here’s a link to the clip instead). Luckily, on Dinosaur Island we don’t have any doors, kitchens, cages, Land Rovers or electric fences so we don’t have to worry about writing the artificial intelligence (AI) routines for the dinosaurs to deal with these objects.

Instead, we’re interested in if the dinosaur can see the food (I discussed 3D line of sight algorithms in, “Dinosaurs, tanks and light of sight algorithms,” here). And, if and only if, the dinosaur can see the food, how does the dinosaur get to the food? The fastest way for the dinosaur to get to the food can be solved using a least weighted path algorithm which I discussed in this blog here.

Now, the question is, “are we making the dinosaurs too smart?” The image at the top of today’s blog is a screen capture of the AI ‘looking’ at different ways to get to the objective (in this case, food that has been identified previously using the 3D line of sight algorithm). From literally thousands of possible routes (some only deviating by a meter from another possible route) the optimal, or fastest route across the landscape (avoiding steep hills and terrain that would slow the dinosaur down) is chosen.

Is this really how a dinosaur thought?

Probably not. What I suspect, and again, I’m a computer scientist, not a paleontologist, is that dinosaurs, especially a dinosaur pursuing prey, ran straight towards the target until it encountered something (an obstacle, a steep hill, swampy land) and only then considered going on an alternative path.

So, I will probably rewrite the AI so it’s not optimal. But for now, we’ve got some really smart predators on Dinosaur Island. Not opening doors smart. But smarter than the real thing.

Below is a screen capture of the optimized AI least weighted path algorithm.

Screen shot of optimal least weighted path algorithms (taking slope and terrain into effect). Dark red lines: 3D Line of sight (the food that the dinosaur is looking at). Orange lines: final path for dinosaur. Yellow areas: alternative paths that were evaluated and discarded. Screen capture (click to enlarge).

How fast could a hungry dinosaur run?

A slide from my comprehensive examination explaining how to calculate the cost of traversing different terrain types. Different terrain types have different ‘costs’ associated with them. When a vehicle (or a dinosaur) travels across a map divided into a grid the distance is calculated (axis or diagonal) and then multiplied by the terrain modifier. (Click to enlarge.)

There are a lot of fascinating web sites that attempt to answer the question, “how fast could a dinosaur run?” One site (The University of Sheffield) even has an online calculator (click here). However, all of these sites – and the University of Sheffield calculator – are based on measuring the stride (the space between dinosaur footprints) and then using a formula (v = 0.25*g0.5*SL1.67*h-1.17  where  (v) is the animal’s speed, (h) its hip height and its (SL) its stride length) to calculate the speed of a particular dinosaur in a particular place ‘frozen in time’.

Was the dinosaur running as fast as she could? What kind of terrain was the dinosaur walking on? Since the measurements are made from preserved dinosaur trackways, the dinosaur was probably walking across wet sand. Dinosaurs could certainly run faster on dry flat land than on swampy land. What effect did walking up a slope have on a dinosaur’s speed?

Dialog box from Dinosaur Island that allows the user to modify the cost of traversing different terrain types and climbing up slopes.

Above is a dialog box just added to Dinosaur Island for adjusting the values of the ‘cost’ of walking across various terrains and the cost associated with climbing slopes of different steepness. These costs are used in the least weighted path algorithm that we discussed yesterday (see How a dinosaur is not like a tank). Least weighted path algorithms are what make computer controlled characters (like dinosaurs) behave naturally and make intelligent decisions. As Ed Isenberg commented yesterday (here) there is no reason to think that dinosaurs, especially predators, could not make intelligent decisions about the most efficient way to get to their dinner.

Least weighted path algorithms and terrain and slope costs, are some of the methods that ensure that Dinosaur Island will be the most accurate and detailed simulation of life in the Cretaceous yet created.

Below is a screen capture of the current values that we are using in Dinosaur Island for least weighted path calculations. These are the values that were used when calculating the movement paths displayed here.

The current values being used for terrain and slope least-weighted path calculations (screen capture).

How a dinosaur is not like a tank.

A cross-section view of the elevation that a T. Rex (named Bob) will have to traverse to get to an Edmontosaurus regalis (named Gertie). A very steep riverbank is between Bob and Gertie. Vertical axis: elevation in meters, horizontal axis: distance to goal in meters. Click to enlarge.

A few days ago I wrote about Dinosaurs, tanks and line of sight algorithms and how my previous work in modeling and simulations (M&S) for military wargames (specifically line of light algorithms) was applicable in Dinosaur Island. Today I am working on the models for dinosaur movement, speed, and what are called “least weighted path” algorithms.

You are probably familiar with least weighted path algorithms even if the term is new to you. Least weighted path algorithms are used to calculate routes in GPS units for cars or smartphones or for various internet sites like MapQuest, Google or Bing. When calculating a route there are a number of criteria to chose from. Does the user want:

• The fastest route?
• The shortest route?
• The most fuel efficient route?
• The route that avoids certain features (such as specific terrain, topography or extreme slopes)?

These options are what ‘weight’ the potential routes in a ‘least weighted’ path algorithm. For example, taking the Interstate is often the fastest route (least amount of time) but frequently is not the shortest route (least amount of distance).

Back in grad school I did my ‘comprehensive exam’ for PhD students on the subject of least weighted path algorithms. There are two very popular algorithms that solve this problem: one is Dijkstra’s algorithm (which is an exhaustive search solution) and the other is the A* algorithm, by Peter Hart, Nils Nilsson and Bertram Raphael. The primary difference between Dijkstra’s algorithm and the A* algorithm is that Dijkstra’s is guaranteed to return the optimal solution but it often takes the most time to calculate. The A* algorithm is much faster to calculate but is not guaranteed to return the optimal (or perfect) solution. In computer games we almost always use the A* algorithm because speed of calculations (especially over large maps) is more important than having the absolutely perfect route. At the bottom of this blog are links to descriptions of these algorithms and my research paper discussing an optimization of A*.

But, what does this have to do with dinosaurs and tanks?

When working on an M&S involving vehicles (like tanks) our primary concern is finding the fastest way for the tank to get from Point A to Point B. Sometimes, we want the tank to avoid entering into an area where the enemy (called OPFOR, or ‘Opposition Forces’ in military parlance) can hit it with their weapons (this is called ‘range of influence’ or ROI). This is illustrated below:

This image shows how MATE will calculate the least weighted path for a unit using roads, terrain and elevation and avoiding enemy weapons range for ‘path weights’. (Click to enlarge.)

We also want the tank to take advantage of roads and avoid swamps, rivers and ponds.The maximum speed of a tank traveling on a road is higher than the maximum speed of a tank traveling across a field. This is not the case with a T. rex or an Edmontosaurus regalis.

Another difference between tanks and dinosaurs is that as long as a tank has fuel it can go at 100% of their maximum speed (on a specific terrain) without problems. This simply isn’t the case with dinosaurs. As dinosaurs expend energy (and remember, energy is the ‘currency’ of Dinosaur Island, see: The currency of Dinosaur Island) they get tired and they can’t run as fast or as far. Also, dinosaurs run at their maximum speed only for short distances and only in extreme emergencies or at the very end of a hunt when they attack.

The illustration at the top of the blog also points out another major difference between tanks and dinosaurs: modern tanks (specifically the M1A1) has a published specification of being able to climb a 60 degree slope at a speed of 7.2 km/h (see here). That’s pretty impressive. It’s unlikely that that a T. rex could navigate a slope that steep. In the cross-section at the top of this blog we show the slopes that Bob, the T. rex, will encounter following a straight line to Gertie, the Edmontosaurus.

Clearly we’re going to need to use a least weighted path algorithm for calculating dinosaur movement so that they will avoid steep riverbanks and crevices. We also will create a table of ‘energy costs’ that dinosaurs will incur as they travel across various terrains (like swamp). These values will be used in our least weighted path algorithm.

• Dijkstra’s algorithm on Wikipedia has a very easy to follow description with a couple of cool animations to show how it works. Link here.

• A* search algorithm on Wikipedia also has a couple of very nice animations to show how it works and pseudocode. Link here. By the way, I once sent Nils Nilsson an email asking him what the ‘A’ in A* stood for and he replied, “algorithm.” Now you know.

• “An Analysis of Dimdal’s (ex-Jonsson’s) ‘An Optimal Pathfinder for Vehicles in Real-World Terrain Maps,‘ the paper for my Comprehensive Exam can be downloaded here.

Herbiverous dinosaurs getting along at the salad bar

You can select what each species of dinosaur eats on Dinosaur Island (screen capture, click to enlarge).

On Dinosaur Island you can select what each species eats. A recent article (quoted at length, below) shows why this is necessary to simultaneously maintain numerous species of large herbivores.

A new study by a Canadian Museum of Nature scientist helps answer a long-standing question in palaeontology — how numerous species of large, plant-eating dinosaurs could co-exist successfully over geological time.

Dr. Jordan Mallon, a post-doctoral fellow at the museum, tackled the question by measuring and analyzing characteristics of nearly 100 dinosaur skulls recovered from the Dinosaur Park Formation in Alberta, Canada. The specimens now reside in major fossil collections across the world, including the collections of the Canadian Museum of Nature. The work was undertaken as part of his doctoral thesis at the University of Calgary under the supervision of Dr. Jason Anderson.

Mallon’s results, published in the July 10, 2013 issue of the open-access journal PLOS ONE, indicate that these megaherbivores (all weighing greater than 1,000 kg) had differing skull characteristics that would have allowed them to specialize in eating different types of vegetation. The results support a concept known as niche partitioning, which dates to the 19th-century studies of Charles Darwin and came into its own in the 1950s with the development of the science of ecology.

A link to the article is here:

Tyrannosaurus rex hunting an Edmontosaurus regalis

A Tyrannosaurus rex (Barney) on the left has identified an Edmontosaurus regalis (Gertie) on the right. Red lines indicate respective dinosaur’s goals (food). (Click to enlarge.)

Today the AI (Artificial Intelligence) routines for the inhabitants of Dinosaur Island to identify food were put in place and tested. The above screen capture shows the results: Gertie, a hungry Edmontosaurus regalis, has spied a forest of Araucaria trees on higher ground about 55 meters to the north-northeast. Barney, a very hungry nine year-old Tyrannosaurus rex has spotted Gertie 145 meters almost due east on the other side of a creek bed lined with Nipa plants. This doesn’t look good for Gertie. Will one and a half football fields be enough of a head start? How long will Barney pursue dinner before the energy expended will be too great? Look at Barney’s health. He hasn’t eaten for a while and he doesn’t have much energy left.

A reminder: the 2D ‘top down’ version of Dinosaur Island is just for testing and scenario creation purposes. Dinosaur Island will be released in full 3D. Dinosaur Island is a unique interactive simulation of real dinosaurs in their natural environment.