Sunday, November 27, 2011

Minecraft: Market

The inspiration for this market based building came from the AoE2 Eastern building set market.



I took the main structures of the outside, but converted the courtyard in to a more aesthetic relaxing area, but left the outer shelters as market booth setups.

Just chillin'
Goods and wares sheltered from the elements.
 The bottom floor contains an indoor market with a bookstore, goods in chests, painting shop and mess tables. There's also a small private room in the corner.

The second floor hosts a private quarters, which includes bedrooms, living room, dining room and a prayer room. The balcony contains a dozen tables with chairs.
Bedroom 1 of  2.
 The construction of this building included a dozen or so creeper incidents. Evidence of these problems can be seen on the  rims of the final project. I swear there's a 10x10x10 hole on one spot from multiple creeper intrusions. As always, all the resources were legitimately obtained. You always get the best adventures that way!


Tuesday, July 12, 2011

Throwing Down an Idea

While riding my bike around the island, this idea for a game keeps creeping in to my head. I have no idea why it's most prominent while I'm biking.

The idea fostered (flowered?) when DavidTo mentioned that Terarria had NPCs that would inhabit the buildings you built. I thought that was pretty cool, but a bit of research led me to the disappointing conclusion that you could only have a dozen or so NPCs. When I went back to playing Minecraft, I felt all those buildings and roads I constructed seemed eerie and desolate. I thought the idea of lots of custom buildings being inhabited by crude AI would add flavour to my masterpieces.

My Minecraft world kinda feel like this.
I have to admit that I actually like looking at the isometric views created by third party converters of my worlds more than I like actually walking around my world. I guess I have a soft spot for the old school city/park builder games like SimCity, Transport Tycoon and Roller Coaster Tycoon.

Nerd Alert! This is actually my desktop wallpaper.
Resource gathering in Minecraft tends to be tedious after awhile. The fun parts of gathering are searching for the resource, laying out a gathering plan and seeing the effect on the world caused by the gathering. I find the actual gathering to be tedious. The same idea goes for building. Designing, planning and watching the progress of a construction site is pretty fun, but laying down floor after floor becomes tedious. What if that tedious bit could be delegated to underlings? Something like the imps in Dungeon Keeper or the ants in SimAnts.

Who doesn't enjoy expendable minions?
Wrap these three ideas together and sprinkle a few other things that I didn't mention and you've got an isometric, open-world, block-based, whatever builder where your main interaction involves highlighting blocks that need to be excavated and delegating where they are to be placed.  As you shape the world, your work is used by the AI inhabitants. I guess it's like a macro version of Minecraft or something.

There are some other details I was mulling on, including interface, neutral AI, multiplayer and world generation, but I'll spare those for now. I have no idea if I'll have the patience to put even a crude version of this together, but I wanted to throw the idea out there.

Sunday, June 26, 2011

Diablo a la Spore Cancelled

I've decided to cancel Diablo-Spore. I simply have no enthusiasm for the project or the game it runs on. Act 3 was almost built, but still required lots of work and tons of testing, which I'm simply not willing to put the time in for. I'll put up a few screenies at some point.

Instead, I'm going to play around with a free form project using java.

Saturday, May 21, 2011

Jump Jump!

While completing a tacked on jumping section of  Diablo a la Spore: Act 2 and messing around other users' adventures I realized how fun jumping is. There's something satisfying about reaching that next platform. I'm sure most of you, gamers or not, know that already, or at least don't find it that difficult to see. What really struck me though, is that jumping is the core of the entertainment.

This ugly, but highly entertaining Spore Garfield romp got me thinking about jumping. (D/L this image and add to spore to try it out)
Okay, truthfully, I'm not just talking about the jumping.  I'm referring to controlling a body to navigate an environment.  This includes jumping, running, climbing, driving and probably a couple other things.  This doesn't include reading text, looking at scenery, shooting, managing inventory, punching, activating levers, opening doors, moving troops, casting spells, picking pockets, quick time events, singing, memorizing, solving puzzles, reloading, sneaking, breaking necks, navigating dialog trees or anything that isn't controlling movement for the sake of moving.

I think this may have been the appeal of the Mario series. The game is 99% about making Mario run and jump. Nintendo stripped out the rest of the crud.  After all, his original name was 'Jumpman'! All gamers can agree there is something satisfying about making Mario leap off a moving platform to land on a smaller parallel platform. Landing that never fails to feel sweet. Who cares about shooting and all that other crap when you can jump?

This is what video games are all about.
Anyhow, I could be totally wrong about this.  In fact, I'd wager in two years I'll look back at this blog and be in disbelief of my ignorance.  Still, I've decided to apply this idea to Act 3 of Diablo Spore.  There's a path that is solely navigate by launch pads and the walkways have more vertical depth. The launch pad section is definitely fun, but I still need to add more variety to the walkways before I can decide if the added navigational challenge makes walking around entertaining.

P.S. While procrastinating editing this article, I came across this bit-tech.net article on jumping.

Saturday, April 23, 2011

Spore: Outsourcing May Be Necessary

Act 3 of the Diablo Spore project is underway.

Kurast Docks

This time around, I've been organized. I laid out the quest plan, recognized the actors and made notes on each.  The notes include what they kind of look like, what their scripts are and any other attribute I want to keep in mind. I actually started writing everything down, not to be organized, but to get my ideas down before I forgot them. I definitely forgot some ideas in the previous acts that came back to me after I completed the adventure.

Since the ideas are all laid out, I just have to build everything.  Putting all the pieces together on the planet is fun. The challenges include spacing, debugging (or deglitching in Spore's case), adjusting flow and other level design aspects. The other building part is creating all the actors (the buildings, creatures, items, etc.). This part is fun, but not as fun as the former creative aspect nor is it the aspect that I want practice. Unfortunately, the latter takes up much more time. Since I already have everything planned, it's painfully obvious how much actor building I have to grind through.

How do I find another's creation that embodie Hratli?
I could use other Spore creators' creations, but how do you find a suitable model for Hratli or Ormus' temple? I've been considering finding someone who might be interested in just pumping out the models, but I have my doubts anyone would be that interested.

Saturday, April 9, 2011

Minecraft: Castle Fort Tour

Earlier, I showed you the framework of a castle.  In an attempt to tie up some lose ends, I've gone back and added a fair amount of detail.  It's no longer some ugly organized stack of cobblestone.


The details actually took a day to put together.  Filling up the moat, picking flowers and acquiring dye for the tapestries were the most time consuming tasks.  Getting the central parts of water to a level height required building temporary pillars to dump water springs around.  For the dye, I needed to spawn a new terrain block, since the current world was generated prior to the patch that included dye. I then set up a temporary base to dig for lapis ore.  Finally, those red flowers to place in the garden and colour the curtains actually required a little stroll. Did I mention I also needed to throw the colours on the sheep to beat the coloured wool out of them?


Another loose end finished up!

Sims 3: Komodo Urbania

Awhile ago I put 99% of a Sims 3 lot together...and forgot about it.  I just came back and fixed it up.

I purposely chose a small lot to keep my goal feasible. I also wanted to try something a little more Miami and a little less Northern.  I present Komodo Urbania...


It basically turned into a one-man spy home.  

I really enjoyed making the jungle like garden and fountain.  Even though it's a cubic home, I honestly think the exterior looks pretty sweet. Faux natural never looked so good.  

There is a rooftop pool, but I must admit, it makes the floor below look ugly.  You can see in the video that the pool wall texture couldn't be painted over.  I came up with the idea of the rooftop pool from just testing the limitations of the tools.  Sometimes just learning your tools bares new ideas.  The same thing happened when I went to see if the secret doors could be painted over.  Now the cellar is accessed via a push wall.  Best protect that liquor.

I might actually do more lots for the Sims 3, the tool is pretty powerful.


Friday, April 8, 2011

Setting up Navigation: A Couple Lessons Learned

While building 'The Sightless Eye' for Spore, I had the goals of not enforcing certain play styles (ex. combat only) and building the planet the way I think it would naturally set itself up.  These both contributed to difficult and boring navigation for the player.

To allow various play styles, I kept the objectives as simple as possible.  For example, instead of requiring a player to "Enter the Cave" and "Kill the Shamen", I just required the player to "Kill the Shamen" and let the going to the cave part be implied.  However, since the mini map only pointed to the actual shamen if "Enter the Cave" wasn't an objective, it makes it difficult to find the cave entrance.  If the player goes off the implied path, they might spend a long time just circling the mountain that envelopes the cave.

The mountains block direct access to the objective, so a player may have to circle most of them if they don't find the entrance right away.
A place that sets itself up naturally tends to spread out more than a conceived setting.  Two towns wouldn't naturally be a stone's throw from each other.  Placing towns and objectives a distance apart in Spore wouldn't be so bad if the mini-map objective pointer wasn't so terrible. Because it portrays an actual (relatively small) sphere, instead of the usual 2D plane, it doesn't account well for the bends, especially at the poles.  The pointer will generally guide you at an arced path to the objective.  Long walks made longer make for boring sessions of just holding 'w'.

Notice the mini-map pointer points perpendicular to the shortest path (the white arrows) thanks to imposing a 3D plane on a 2D graphic.

The navigation flow of a 'natural' setting.
Since I realized this near the end of making the adventure, I tried to rectify it by placing big giant arrows that pointed in the right direction. Sadly, I was already near the complexity maximum, so I couldn't add many arrows, and the ones I did were only useful if you were already on the right path.

The lone arrow tells you to just go through
the bush and hope for the best.
Better arrow placement through town to a followable road..
For "The Secret of the Vizjerei" I made less wilderness paths (more actual pathways), compacted the objective locales and placed more effective arrows.  Overall, this worked without compromising the feel of the adventure. Sure, if you thought about it, those abandoned ruins are awfully close to town, but the suspension of disbelief covers that.  Adding actual paths also added more detail to the map.  The treks between objectives are better paced and more enjoyable in the second adventure.

The navigation flow of a 'conceived' setting.  Also note the use of pathways between locales.
I still want to do a better job at incorporating direction into dialogue, but I've taken some good lessons from building the first adventure applied them to the second.

Monday, April 4, 2011

Spore: Diabloesque Act 1 & 2

I've just finished up Act 2 for the Spore version of Diablo. I've taken quite a few lessons from creating Act 1 and applied them to Act 2.  I think Act 2 is a bit easier, with prettier scenery, and much less walking.











Be sure to check them out and don't forget to leave some feedback! I also hope to have a short blog about my lessons in walking distance and player navigation posted on Wednesday.

Saturday, January 29, 2011

Age of Empires 2: Startup Tutorial to AI Scripting - Part 2 of 2

Continued from Part 1

Advanced Script
Lets take the previous script and beef it up to demonstrate a couple more concepts. This time around, the script will build a small army of men-at-arms and attack an opponent.

Once again, due to formatting and length reasons I've uploaded the script file.  Just download it and open it with your text editor.

Now we're scripting!
Advanced but Important
If you look through the script you'll notice I added a wild-card parameter, some constants, some not-so-obvious facts and actions, a couple important strategic numbers and a goal.

Wild-card Parameter
If you look at the rule that trains the military unit, you'll notice that instead of "militiaman" or "man-at-arms", it trains a "militiaman-line". This wild-card parameter trains any of the unit-types that can be upgraded from a militiaman. This kind of parameter helps save rules by allowing you to not have to add redundant rules for training militiamen, men-at-arms, long-swordsmen, etc.

Constants
At the beginning of the script, I added a few constants to make my script easier to read and edit. A constant allows me to substitute a value with a name.

(defconst [name] [value] )

This means that after this constant declaration, you can put the name instead of the value in rules. Constants are best used if you plan on using the same value in many rules, but may need to change the value when adjusting your code in the future. Instead of changing all the values in each rule, you can just change the value in the constant declaration.

'True' and 'Disable-self'
The fact 'true' is useful for setting up strategic-numbers and goals to your preferred default values. If 'true' is the only fact, then the rule is always run.

The action 'disable-self' allows you to run a rule one-time and then never again. It is useful for turning off a rule with 'true' as a fact, like the advanced example script shows for setting the initial value of goal 1.

Builder Distribution
Just note that 'sn-percent-civilian-builders' and its sister number, 'sn-cap-civilian-builders' should be set to 100 if you want your 'build' actions to happen immediately. If you ran the first script, you may have noticed that villagers did not build a building the moment the facts were true. This is because the 'build' action actually puts the building action in a queue and only once a villager is free does the villager build.

The strategic number 'sn-initial-exploration-required is also usually set to '0' if you want your villagers to begin building as soon as the map starts.

Stop gathering and build me a house, dammit!
Goals
The most important concept I added to the new script was a goal. These are the user controlled variables of Age of Empires AI scripting. In the above example I used goal 1 to indicate whether the script should build an army (value of 1) or not (value of 0). Just to note, the line "(goal 1 0)" is read as "goal 1 is set to 0". Sadly, you can't make more broad comparisons than this using '>' or '<'.

While I didn't use a constant to replace '1' in the above example, it is common practice to do so. For example, I could have used the term 'build_army' to indicate goal 1 with the following:

(defconst build_army 1)


(defrule
(true)
=>
(set-goal build_army 0)
(disable-self)
)

You can have 70 goals (1 through 70) and the value of goals can range from -32000 to 32000.

Processing Your Script
Okay, hopefully you now have an idea of what an AI script looks like. It's time to mention a few details of how exactly the game processes your script and some of the implications.

Rule OrderThe game frequently runs a pass on your script from top to bottom. This means that your first rule will always be read before your second rule. Which in turn means that the following two scripts will yield different results:

Script 1
(defrule
(can-train archer-line)
=>
(train archer-line)
)


(defrule
(can-train skirmisher-line)
=>
(train skirmisher-line)
)


Script 2
(defrule
(can-train skirmisher-line)
=>
(train skirmisher-line)
)


(defrule
(can-train archer-line)
=>
(train archer-line)
)

The first script will try to train an archer in an archery range before a skirmisher and the second will do the opposite.

The 'can-build' Rule
A script can only attempt one 'build x' action through a single pass of the script.  This means that using the 'build x' rule when the AI doesn't have resources or space to build 'x' will cause all the following 'build x' rules to not run.  To prevent this, make sure you always use the 'can-build x' fact in rules using the 'build x' action.  You don't need to use 'can-train x' and 'can-research x', but they are useful if you have actions other than 'train x' or 'research x' in the rule.

Wrap Up
I hope that you now have the knowledge to produce an AI script or at least take an existing script and play around with it. Remember, this guide was meant to get you as far as making a functioning AI. There are still many topics that are left untouched here that need to be learned before you can produce a full-scale AI. At the end of this article, I've left some notes on important further reading. Still, your best resources are the AOKH forums and the AIScripters forums. Thank you for reading and best of luck with your AoE projects.

Further Reading
Town Size Attack (TSA) - TOAO_DaVe's Guide
Walls - see "enable-wall-placement" in CPSB
Load Statements - see "Load Command" and "Conditional Statements" in CPSB
Escrow - Scripter64's Guide

Age of Empires 2: Startup Tutorial for AI Scripting - Part 1 of 2

Lately I've noticed a lot of hits to this blog coming from google searches for terms like "age of empires", "ai", "scripts", "scripting", and "guide".. Although I know there are some guides out there (because I read them), they seem to have been lost in the intertubes. I hope to fill this void by providing a short guide that gives interested scripters enough knowledge to write their own crude code..

You too can create a siege happy AI!
As mentioned, the goal of this guide is to introduce you to the basics of scripting AI for Age of Kings and allow you to start playing with your own code as soon as possible. By the end of this tutorial you should have the knowledge and resources to write and run an AI script.

Tools
Before you begin scripting, it is important to have the right tools and references. If you skip getting familiar with any of these, you will make scripting much harder for yourself.

An AIScripters Account
Almost all AoE2 scripters go here to discuss problems, share ideas and post resources. This forum contains a wealth of knowledge. Sadly, you need an account to access them, and each account is personally authorized, so it might take some time before you can access the site. If you sign up for an account and don't get a response within a week, contact Leif Ericson (from Age of Kings Heaven) or me.

An Age of Kings Heaven Account
While AOKH doesn't have the depth of discussion that AIScripters has, the AI & RM Scripting forum has many active members that can help answer simple questions. You can also find the continuous AI Scripting Ladder here.

CPSB
You can find this document in the "DOCS" folder on your AoE2 Expansion CD. You can also find a .pdf version here. This document contains a thorough introduction to scripting concepts, and more importantly it contains lists and descriptions of parameters, facts, strategic numbers and a bunch of other fun things.

New RMS Guide
While this guide is intended for Random Map Scripting, it contains unit reference numbers. These numbers are important for more intricate rule writing.

ScriptEd
This is the best text editor for writing AoE2 scripts. Since you need access to AIScripters to get it, you can use Notepad or AoK AI Editor in the mean time. Be warned that AoK AI Editor was not upgraded to work with Age of Conquerers code changes, so it will show errors that are not actually errors.

VegMod and/or another computer.
Vegmod allows you to play in windowed mode. This may seem trivial at first, but being able to quickly switch back and forth from testing to coding saves a lot of time. The same idea applies to having another computer testing your script while you code on the other.

Cheat Engine
Cheat Engine allows you to fast forward the game.  This allows you to test your scripts at a faster rate.  While I've never used it myself, other scripters recommend it. 

Introduction Script
Before I start blabbing on about how the game processes the script, lets just take a look at a simple script that trains villagers, advances to the Feudal Age and then researches 'town watch'.

For formatting and length reason, I didn't post the script here, so please download the uploaded copy and open with a text editor (like ScriptEd).

Now we have a basic script to work with. You may not understand all the rules in there yet, but that's no big deal. Lets just get this script running on a random map.

Saving & Running
1) Copy and paste the above script into your text editor. Save the file with the name of your choice and with a '.per' extension under the AI folder (default: Program Files/Microsoft Games/Age of Empires II/AI).

2) Open a new document in your text editor and save a document in the same place with the same name as above except with an '.ai' extension. This file lets the game know that "Hey, there's a '.per' file with the same name as me that contains the beginning of an AI script".

Note the folder contains both a '.per' and '.ai' file with the same prefix.

3) Run Age of Empires 2, go to 'Single Player' and then 'Standard Game'. On the left side, your profile name should have a drop menu that lets you select your AI. Select your AI.  Make sure you select the AI after adjusting your game settings because sometimes this causes the AI selected to revert to the default once you begin the match.



4) Click 'Start Game'.

Note: If you make any changes to your script and want to test them out, you don't need to go the main menu and start a new game, you can just restart the match from the in match menu. This is especially useful for fixing script errors.

Note II: In the in-game options menu, set your game speed to 'fast' for more efficient testing.

The Basics
Okay, now you've seen a script and maybe took the time to run one. That's great at all, but you want to learn how to write some code! Lets take a closer look at the basic building blocks.

Rules
Rules are how you tell the computer when to change what. Here's the setup of a rule.

(defrule [this just says "Hey, this is the start of a rule!"]
(fact 1)
(fact 2)
...
(fact x)
=> [this symbol indicates the transition from facts to actions]
(action 1)
(action 2)
...
(action x)
)

If all of the facts before the arrow are true, then all of the actions after the arrow will be initiated. Compare this frame to some of the rules in the example script above to make sure your comfortable with the idea of a rule. To look at all the available facts and actions that you can plug in to this frame, open up the CPSB and look at the 'Fact List' and 'Action List'. It is really that simple.

There are some limitations regarding rules. A rule can have a maximum combination of 16 facts and actions (this includes 'and' and 'or' which you'll learn later). A running script can have a maximum of 999 rules.

Strategic Numbers
You may have noticed that the script does not provide any details about where buildings are built or where units go. Yet if you ran it, you'll know that the villagers happily went on their way harvesting trees and butchering sheep. You can not control units directly via scripting, but you can mold and shape their behavior with the use of strategic numbers. Once again, you can find the entire list of strategic numbers in the CPSB.

The example script only used one set of strategic numbers to ensure the villagers split up their wood and food gathering duties. The example shows strategic numbers being compared as a fact and it shows them being set as an action. When the AI is trying to decide where to task a unit, it uses these strategic numbers to aid its decision.

Comments
I named each rule in the example script. I did this through the use of comments. To indicate a comment, just put in a semicolon (";"). The game will ignore anything on the line after a semicolon. The example script contains sparse commentary, but It is highly recommended that you comment your work thoroughly to make it more legible for yourself and others.

Onto Part 2

Sunday, January 23, 2011

Minecraft: Castle Fort

While I was initially shooting for a castle,  space limitations constrained me to more of a fort.  I did my best to  keep the natural valley walls and build within it, opposed to completely levelling everything.  The castle still needs landscaping in the courtyard and various detailing.

North daytime shot.

South night shot.
In both the panoramic shots, you'll notice the lack of approach to the gate.  I plan on adding a moat on one side, a ramp on the other and gates to both.
Unlandscaped courtyard from wall.
In the courtyard, I'm planning on putting in a small pond, flowers, trees, pathways and a portal.

Partially built, walls up, but no towers.

Quick draft.
I did a really quick draft because drafting the temple helped me immensely.  Sadly, I tried to skip out on a front or side angle and wound up screwing up my draft a fair bit.  In the draft, the walls were only supposed to be three tiles thick with crenellations sticking out an extra tile on either side.  In the final castle, I accidently built the walls five tiles thick and an extra tile for the crenellations.  Being lazy didn't pay off this time around.

Minecraft: Temple Drafts

Here are the two drafts I put together before putting up the temple.  I'm fairly confident there is a mistake in one of them, but I can't remember where exactly.  Basically, something looked okay on paper, but wasn't possible in 3D.



You may notice a few numbers in the corners.  Those numbers were from me trying to figure out how many stone pieces I needed for a few of the sections.

For projects that require lots of numerical caculations (column spacing, layers, etc.) drafting the project first is much better than just winging it.  Not only do I finish the project quicker, the building looks better in the end because I don't compromise my design when something doesn't quite fit.