Welcome to Unknown Horizons

How the settlement AI works
Posted at: Sep 11, 2011 by gscai
Categorized under: »Summer of Code »Coding

During this year's Google Summer of Code I worked on a computer player (artificial intelligence) for Unknown Horizons. In this post I will give a quick overview of how it works from the player's perspective.

The first task of any player is to choose an island and found a settlement. The AI's primary motivator for choosing an island is the amount of available flat land but other factors such as the positions of existing settlements and available resource deposits are taken into account. The final choice is made randomly with a larger probability for choosing the better islands. This tends to make it more fun for the human and spread out the computer players. At this stage the AI also decides which part of the island it is going to be using for the village and which part for resource production.

Player score widget with AI playersOnce the settlement has been founded, the AI starts building tents for the settlers. It will keep building more tents until the village area is full or it notices that it isn't producing enough of some resource. To satisfy the resource demands it uses the game's internal data to find out its estimated resource production capacity and the settlers' current resource usage along with the data about which building produces what. This is one of the parts where the AI has an advantage since the human player doesn't have direct access to it.

When the AI knows that it wants to build a specific building, it has to decide where to put it. For tents and village producers (pavilions, schools, taverns) this is decided when the settlement is first founded by dividing the village area into sections with one main square each and then trying to place as many tents as possible. The village producers then replace some tents to achieve maximum coverage. Most other buildings are placed without a prior plan by trying to put them into a sensible place. This depends on the exact building type but most of the time it is influenced by alignment (causes new buildings to be pulled towards existing boundaries) and distances to resource producers (weavers should be close to farms with pastures). Farms and lumberjacks are special because they must be right next to their input resource producers which is why field positions are decided when farms are built.

There are many reasons why the AI could choose to add storages. It could be trying to increase settlement storage capacity, extend the settlement area to some fixed position, enlarge area reachable by collectors, or improve collector coverage. The first three are relatively easy while the last one is a bit trickier. The chosen solution was to add better statistics about collector utilisation and production building capacity utilisation. The AI uses this information to find out the buildings that could most benefit from an extra storage and then places it in a badly serviced area.

Basically the AI is trying to play like a human player who wants to have as many settlers as possible and make them as happy as possible. We hope you enjoy playing with the new AI; it should be a lot more fun than just watching the pirate and trader move around.



Summer of Code results are here!
Posted at: Aug 28, 2011 by Christopher Oelmueller
Categorized under: »Coding »Main Development »Summer of Code

Heya!

Since our last posting is rather old already, we'll update with the big news today: during last week, both Summer of Code students working with UH finally merged their results into master. This means that you will see a combat system and AI players our next release!

Let's again summarize what gscai and mihaibivol created over the last few months (a plus as huge as 55% of the lines of code we had in April, according to ohloh, now at about 60k)! Within the next weeks, all our students will probably write a blog post on their own about how their summer went, we will link these postings here after they are published.

First of all, there's our artificial intelligence system (click here for the original proposal which we selected). gscai literally started with nothing but his mentor nihathrael and the code that drove our free trader around the map and created a tough player that is able to look for a nice island to settle on, divide that islands into parts with different purposes, deal with inhabitant needs and taxing, produce goods, optimize collector coverage, watch production chains and consumption stats, react accordingly, buy and sell resources as needed, deal with other players, expand through feeder islands where more resources are cultivated and then shipped to the main island by trade routes, conform to several hundreds of personality constraints where you can tell the AI how to behave in an intuitive file format, well, I will only stop now because this sentence needs a period at some point, but really: the only thing that it does not know about right now is combat -- because this had been worked on during the same time in a different branch :)
As a player, the important news is that you can select a number of AI players when starting a singleplayer game. Oh, and you will need to be quick, else they will take all cool islands and only leave you a very small patch of ground to settle on. All this is achieved without any cheating by the way, our AI gets the same starting resources as any human player, has the same building pool and uses the same balancing values!

On to our second huge and brand new feature: War! Cannons! Destruction! Aww, sorry, still like it? mihaibivol, mentored by totycro, implemented his combat system proposal which, amongst others, included the classes FightingShip and FightingGroundUnit; unit stances such as aggressive, hold ground or flee; combat based on individual weapons which are equipped to units; cannon tower as defense building; design of tabs for single units and unit groups; a diplomacy system that currently knows Friend, Neutral, Foe and behaves accordingly if you deliberately attack units of players not your enemy before; and finally a lot of calculations under the hood when it comes to damage dealing.
As a player, you will also see new graphical content such as the cannon tower, our awesome new ship model, the attacking tool cursor, new tabs, icons for stances and so forth. We currently work on a dynamic boat builder that actually allows you to build ships with cannons and will definitely include this in our next release!

As you might remember, kozmo was selected to improve our engine FIFE with both vtchill and prock as his mentors and the results of his reconditioning are just great! Only a few of the many improvements available for FIFE 0.3.3 are: support for atlas files, animation spritesheets, batching and the experimental OpenGLe renderer (check his application proposal here).
Just to give some numbers, FPS on average improved by 200 % and the atlas files also reduced the disk space consumed by our assets from around 30 MiB to 10 MiB. Additionally, kozmo kept a branch in our repository up-to-date with these FIFE API changes and has as well merged all new UH stuff in already. This helps us hunting bugs while keeping our master stable for you.

After the new FIFE release in roughly four weeks, we will do our best to quickly follow up with packaging all those new features into Unknown Horizons 2011.3. Stay tuned :-)



Unknown Horizons combat branch test
Posted at: Jul 9, 2011 by mihaibivol
Categorized under: »Summer of Code »Coding
Hey everyone!
As part of Google Summer of Code mihaibivol works on developing a combat system for Unknown Horizons.  Now ships are equipped with cannons and there's also the possibility of building a cannon tower.  Attacking is done via right mouse click over enemy units or shift + right mouse click on a unit of an allied player in order to betray them.

There are many design issues to decide (e.g. what should happen exactly when a ship set on defensive gets attacked? Should it flee or just shoot back? Which target should a ship set to aggresive pick?...).  In order to create the best possible user experience, we want to know your opinion. For testing you need to clone the repo following these steps http://www.unknown-horizons.org/download/sources/s-linux/ and then move to the combat branch by:

$ git checkout combat
$ git pull origin combat
If you have already cloned the repo get the combat branch by:
$ git checkout -b combat

Now the player starts with 8 ships, and other 6 players are created, each having 3 ships set to defensive stance. Currently there's no UI yet for changing the stance. Try different attacking positions, various attacks and tell us what goes wrong and what you think needs to be changed.

Please leave your feedback in our forums at http://forum.unknown-horizons.org/viewtopic.php?f=27&t=506.
We will discuss the suggestions on Sunday 17:00 UTC, at the weekly meeting on IRC at #unknown-horizons on Freenode.

So long,
Your Unknown Horizons Team


Decisions have been made
Posted at: Mar 17, 2011 by eoc
Categorized under: »Coding »Main Development

Heya and welcome to another short update!

In our last meeting we discussed the current blocker issues that currently prevent us from releasing. We addressed these two as showstoppers:

  • Problems with sheep
  • Problems with fisher and boat builder

Because we want to release as soon as possible, we decided to implement workarounds for both. The sheep will temporarily be replaced with an animated pasture that produces lamb wool just as e.g. the potato field produces potatoes. We hope to be able to fix all bugs related to sheep (together with new graphics) in 2011.2 then. You won't believe how hard this hunting is.

The fisher on the other hand needs a bit more work. As we blogged some time ago, we implemented the fish resource and a boat for the fisher. Current problems happen because our boat builder can also build fisher boats and the code for assigning them is not even in planning stage right now. So we will also use a hotfix here and have two fisher boats: One that belongs to each fisher and will collect fish, one that you can build and drive around with at the boat builder.

Once these preparations are ready, there are only smaller problems and we think that's acceptable for a development release. This especially means that if you have a clone of our git repository at hands and want to test the status quo, please help us in removing balance issues and bugs you possibly encounter!

Thanks and kind regards,
Your team of Unknown Horizons



Time's running
Posted at: Feb 26, 2011 by eoc
Categorized under: »Project Coordination »Coding

Heya,

we still try to give feedback on a way more regular basis, so here comes right another update. It has already been two weeks since our last entry!

Merging master

In case you remember me writing about the new tile set structure: it is still under development. Because we want to release UH 2011.1 anytime soon, we merged all features of the dev branch into master (with the old maps still being playable there) and plan to fully implement the new tile set in 2011.2.

The only bugs we found so far with the merge were related to the boat builder, which is a rather nice quota for merging more than 200 commits into a branch that had its own commits in many files as well. We would like to encourage anybody: Please test and report bugs you encounter, else we possibly cannot fix them!

Replacing content that's not free enough™

Who has not fiddled around with this funny, funny topic of licensing? Sometimes it just is not enough to willingly fulfill all conditions the creator asks for through the license — it's still considered not free by distributions we would love to see UH packages shipped with.

In our particular case, the whole bunch of animated human units is affected (provided by Reiner's tileset which is covered by his own Freeware license). We even consider a separate "very free" release version of UH with fancy black CC0-boxes instead of cute podgy inhabitants. This might attract contributors if they *really* see what we are missing.

Opinions welcome: Would you appreciate such an additional release version or do you see it as unnecessary workload?

Another issue comes up with our sounds. There are a few sound effects which we sampled from tracks obtained through freesound.org. Sadly, their CC-Sampling+ won't make it into Debian, so we need replacements here, too. hazure was kind enough to put the work we use under CC-BY-SA 3.0 as well, but I fear that not everybody is that lucky. Props for doing us this great favor!

Google Summer of Code 2011

Now on to the most important news of this entry: We decided to apply for this year's Summer of Code. What are our expectations? Well, of course we hope to get accepted, gaining new coders and trying our best to keep them with our project after GSoC ended. But even if the application is not successful, we still made ourselves clear what we would like to work and be worked on in the next rough 6 to 9 months.

The preparations for applying are a rather large task and I work on this for almost three weeks now. Collecting and sharpening ideas for our students, preparing mentors for their task and setting up the overall infrastructure is nearly finished by now. The current plans are to set us a limit of four student applicants at most. We are a small organisation and as such won't try to take care of ten students. It is simply not going to work – and not fair to mentors and mentees alike if there is not enough time to properly answer questions and be a guidance ;-)

If you by any chance are interested in working with us this summer (and longer of course): Visit us on IRC, introduce yourself, try to get familiar with the tools we use and you are likely to be recognised when it comes to selecting students. A good start for that would be the next public meeting in our channel, which is currently scheduled for Sunday 14:00 UTC+0.

So … coming to an end, I'll just copy several old lines and add something new:

Not only are graphic artists needed, even playtesting users, evolving into professional bug hunters, are of invaluable help. For new features, we also need requests and thoughts about how they could look like. Feel free to throw anything in our channel or bugtracker – and be assured that we will evaluate it!

Help wanted:

  • 3D-modelling, urgent need ;-)
  • playtesting and balancing, can be done by everybody
  • animation, human models

Of course, if you are an interested programmer or have something different in mind, we can also make use of anything you work on – we are not only open to students that want to join the team! If you are a C++ developer, you might also consider lending our engine FIFE a helping hand. We directly profit from any performance gain.

Regards
Your team of Unknown Horizons



Status update
Posted at: Feb 7, 2011 by eoc
Categorized under: »Coding »Media »Main Development

Heya,

I'd love to tell you that nobody applied for writing an update post because we are so busy improving Unknown Horizons. Well, that's true to a certain degree: The part with busy holds true.
Besides all the stress we felt recently, there still was and is some progress though and we decided that is it about time to tell you (-,

Code improvements

Most importantly, we are implementing a new tile set structure that will allow us to provide a working island and map editor soon. In the meantime, if you are running our git source, only random maps will work on branch development.

Another not-so-visible improvement has been made to our folders. Cleaning up the structure that in most parts was more than two years old hopefully eases navigation through our code- and contentbase. There also have been new scenario conditions added in master, but you'll need to wait for our new maps before excessive testing and usage of these.

New game content

On to stuff you see and like to see: content, content, even more content. We have added a whole third increment to the game! You can now help and watch your inhabitants progressing to the 'settler' level. The main goal there currently is to produce tools. 
For that, you need a toolmaker.
For that, you need charcoal and iron ingots.
For that, you need a charcoal burning and lots of lumber as well as a smeltery.
For that, you need more charcoal and iron ore.
For that, you need iron ore deposits.
… you need … so much … wait.
Yep, we even have implemented the natural form of iron ore deposits: mountains!*

Shortage on graphic artists

As you see in the above list, there is a lot of parts you need to assemble a working production chain. Sadly, we have not enough graphics artists to produce high-quality assets that can go straight into Unknown Horizons. manthus has provided great pieces of work with the charcoal burning, the toolmaker and several (graphical) building upgrades you will find in the pioneer increment, but some buildings still only exist as placeholders. They are found under the component 'Graphics' in our trac and have a high priority. The smeltery for instance likes to get replaced for sure. Another task is creating a housing for our settlers, right now they reside in pioneer log huts. Help! They want half-timbered quality standards!

If you are interested in contributing and are able to put your work under a CC or GPL license, give it a try! We'll honestly not reject you, visit us on IRC, post on the forums or in our bugtracker.
* Or a first step towards having mountains at least. You'll see what I mean

here in this new picture!

Maybe we'll also show two of them.

All improvements are of course welcome, the mountain graphics are likely to be replaced if we have better ones available.

More new content

That said, let's sum up what other upgrades I talk about. We also added a field with sugar cane (P) and a distillery (P) for liquor. A tavern (P) uses this alcohol to produce another kind of get-together-and-meet-pals resource which increases tax income. These (P)-buildings lack proper graphics right now, too. New pioneer versions got added for the pavilion and the signal fire, more to come. If you help :)

We further populated the sea with a fish resource. This means that the fisher can only work properly if there is a school of fish in range now.
Still work to be done, of course, the animation e.g. looks odd and is synchronized all over our archipelago, but that's a huge step in the right direction already.
Later, you will be able to build boats at the boat builder and assign them to a certain fisher. A fisher without boat will only be able to hang around fishing with a rod, that is not the most effective way for sure.

To wrap up this huge text: We are moving forward, there is progress, but it could be better. With exactly your support. Not only are graphic artists needed, even playtesting users, evolving into professional bug hunters, are of invaluable help.

Help wanted:

  • 3D-modelling, urgent need ;-)
  • playtesting and balancing, can be done by everybody
  • animation
Of course, if you are an interested programmer or have something different in mind, we can also make use of anything you work on!
For any questions, simply join our IRC (linked above) -- you might need to stay for some seconds however ;-)

Kind Regards
Your team of Unknown Horizons