The Age of Empires II Technology Trees In Your Web Browser

Age of Empires II currently offers 31 unique civilization to play as. Compared to, for example, the three races that players can choose from in StarCraft 2, that might seem overwhelming at first. However, all Age of Empires II civilizations share a common pool of units, buildings and technologies, with only a few unique elements to each civilization. This lowers the bar for newer players significantly.

A civilization’s technology tree shows which units, buildings and technologies are available to that civilization in which age. This follows some general rules, like that mesoamerican civilizations do not have access to cavalry, and further civilization-specific rules that disable certain units and technologies for a civilization. Due to the common pool, all technology trees look similar, albeit not identical.

The Age of Empires II Technology Trees In Your Web Browser

The leftmost part of the Japanese technology tree

Sometimes, players wish to access the technology tree for one or more civilizations without having the game open, to see which units, buildings or technologies are available to a civilization.

Let’s build an online technology tree!

We start by analyzing the layout of the in-game technology tree:

  • There are eight rows, two per age.
  • Squares are connected  by exclusively horizontal and vertical lines.
  • Elements of one upgrade line are all within the same column.
  • Buildings are centered on their immediate unit and technology children.

Sounds doable!

Our next step is to collect all available building, unit and technology names. We devise a clever algorithm to recreate the desired layout that contains the data we collected before.

Next we notice that some civilizations have unique units, which move parts of the tree around when they are inserted.

Crestfallen, we exclaim „Oh no!“ and scrap the idea of an accurate representation of the in-game tech tree, because while we are rather motivated, we are first and foremost lazy programmers.

Instead, we create a „master“ technology tree which contains the elements of all technology trees in the game. Unfortunately, this means that it gets even wider than the original version(s). Also, some squares will be disabled for 30 out of 31 civilizations, but whatever. At this point, we don’t care.

Speaking of disabling: We add a the functionality to display big red crosses when an item is disabled. Hereafter, we spend two hours scrolling through the tech tree of every civilization and adding the information which buildings, units and technologies are disabled to our application.

As a finishing touch, we add all the icons, and we are basically done!

The Age of Empires II Technology Trees In Your Web Browser

Add dank memes to your blog posts to boost your reach among adolescent audiences.

We present: A bland online version of the Age of Empires II technology tree. In your browser, even kind of mobile-friendly, MIT-Licensed (except the icons).

Unfortunately this version is currently without the civilization bonuses that are usually displayed below the civilization selection box, as we could also not be bothered to manually type them all.

Filme zu Barcodes!

Eine simple Idee: Man nehme einen Film, ermittle die durchschnittliche Farbe jedes Frames, lege diese Farben hintereinander, ziehe das Ganze etwas in die Höhe und voilá: Kunst.

Eine derart simple Idee können wir auch selbst umsetzen!

Zunächst basteln wir ein kurzes Python-Script, welches einen Film in ein Streifenmuster umwandelt:

#! /usr/bin/python3

import imageio
import numpy
import argparse


def main():
    parser = argparse.ArgumentParser(description='Convert a video into bars of colour.')
    parser.add_argument('video', help='The video file to process')
    parser.add_argument('image', help='The output image file name')
    parser.add_argument('--height', type=int, default=600, help='The height of the resulting image')

    args = parser.parse_args()

    reader = imageio.get_reader(args.video, 'ffmpeg')

    colours = []

    for i, im in enumerate(reader):
        print("Processing frame {}".format(i))
        colours.append(numpy.mean(im, axis=(0, 1)))

    resultpicture = numpy.repeat(numpy.array([colours]), args.height, axis=0)

    imageio.imwrite(args.image, resultpicture)


if __name__ == '__main__':
    main()

Hernach können wir das Bild noch ins gewünschte Endformat quetschen:

convert -resize 600x200! image.png image-resized.png

Und fertig!

Zu Anschauungszwecken habe ich mir mal ein paar Youtube-Videos genommen und in Barcode-Form gegossen. Ein Klick auf das Bild bringt euch zum zugehörigen Youtube-Video. Vielleicht erratet ihr es aber auch bereits vom draufsehen?1 Am interessantesten finde ich persönlich ja das letzte Bild.

Filme zu Barcodes!

Filme zu Barcodes!

Filme zu Barcodes!

Filme zu Barcodes!

Filme zu Barcodes!

Filme zu Barcodes!

Filme zu Barcodes!

Filme zu Barcodes!

Filme zu Barcodes!

  1. Wahrscheinlich nicht.

Everything is Regicide – now with Treason

In Everything is Regicide with UserPatch 1.5 I described how to turn any random map script into a custom regicide map, with the help of UserPatch 1.5 and the guard_state command.

However, regicide is only half the fun without the Treason1 technology. For the mere cost of 400 gold, it briefly reveals the positions of all enemy kings. Treason can also be researched repeatedly, making it easier for you to hunt those kings down and eventually kill them, defeating the player instantly.

Treason is only available in regicide games, where it replaces the Spies technology2. Treason could hence not be used on the custom regicide maps above. The latest update of UserPatch 1.5 however allows us to manually enable the technology in our random map script, without the use of any mod!

Adding Treason to Custom Regicide Maps

First we need to define three constants at the top of the script (if they are not defined already):

#const GAIA_SET_PLAYER_DATA -10
#const DATA_MODE_FLAGS 1
#const ATTR_SET 0

Now we can mess with the availability of Treason and Spies in the <PLAYER_SETUP> section by adding an effect_amount command:

<PLAYER_SETUP>
  […]
  effect_amount GAIA_SET_PLAYER_DATA DATA_MODE_FLAGS ATTR_SET 1

The value 1 at the end enables the Treason technology, the value 2 disables the Spies technology, and the value 3 does both (so Treason is available while Spies is not).

I have of course updated all the custom King of the Hill Regicide maps over at Github to include both Treason and Spies: click me

Have fun!

Does it have to be a king?

The guard_state option not only works with kings, but with arbitrary units.

Supposedly, Treason also works with other units that a guard_state is set for. If there is a king, it is revealed, else one guard_state unit is revealed. This behaviour is not necessarily ideal, but without doubt better than before.

  1. (the medieval kind)
  2. For the mere price of 200 Gold per enemy villager (min. 200, max 30.000), Spies reveals the line of sight of all enemy players‘ units.