Jedi/Rockstar/Ninja in Development

How I'm learning to be a master coder

hide

Read Next

Some things I didn't know about Python

I just did my first interview in Python and it turns out I made the switch from Java prematurely. Disaster. Here are some things I didn't know.

Constructor overloading. Function overloading is when a function with the same name is defined in two different ways and distinguished by its parameters. In particular, constructor overloading would allow you to instantiate a class in two different ways. Say a rational number that is defined either by two ints as a/b or by one float. Does Python have function overloading? I didn't know.

It turns out Python is quite flexible in its parameters and relies on that flexibility rather than method overloading. So for the rational number example, you could either have two optional parameters and check them, or you could have a dictionary datatype where you check.

Throwing exceptions. The interviewer was insistent that my class constructor conform to the two constructor options, so my suggestion was to check the parameters and throw an exception when it didn't work. Of course, I didn't know how. The keyword in Python is raise, and it can either be called alone or with an exception object (which can be user-defined). See more at http://docs.python.org/2/tutorial/errors.html

Identity testing. Later, I wanted to test if two objects were the same object in memory. I suggested == but it turns out this does a value equality test. For a custom class, you need to define an __eq__ function to determine equality and without that == is true only if they are the same object (though I'm not completely sure about this). So technically I think it worked. But the right way to test for the same object in memory is Python's is keyword:

Territory Generation

On Gorilla Tactics

Here is the first video of Territory Generation! So I've showed off the World Generator before, and now the Territory generator. What's the difference, you say? Well Phil (Your name is now Phil) the World Map is like a... uh... map of the world, where the Territory map is more like a map of a city, or your local town. The Territory map is where you play the game, so to speak. Command your monks (or try to), and face down horrible enemies (or run away).

Each territory is generated based on its biome type, and the biome types of the territories that surround it on the world map. A random pattern is then chosen for each biome type, and it is placed on the territory. For patterns I mean stuff like "Circle" or "Semi circle" or "small groupings of islands", etc.

I'll have more to show off soon, once we get the water color washes implemented and some actual trees and objects and what not put in.

Rendering New Theme...