Friday, 30 September 2011

Version 31, pretty much done and open source

Well, this will be the last version I'm making of this thing for a while (except minor changes if anyone requests them). Everything is nice and polished, there is even a level editing guide! Also, I've published the source code here:

https://docs.google.com/viewer?a=v&pid=explorer&chrome=true&srcid=0B5PuXECqHeVYZGU4ZTM3NjgtYjVhNC00OTI1LTg3N2ItYTNkYTVkYzg2MjE0&hl=en_US

Feel free to change something and run it yourself, use my levels in there as a starting point for your own, mock my coding style, whatever :)

I hereby release the source code under the WTFPL, CC0, every GPL-compatible license, and into the public domain if allowed in your jurisdiction. Standard intimidating uppercase warranty disclaimer applies.

If you need any help - tips on editing levels, clarification on how the code works, whatever, just contact me - you'll make my day more interesting as well!

Once again, the link is http://vubslasha.appspot.com/

Monday, 5 September 2011

Version 20 - a rudimentary level editor!


This will probably be the last release of my summer productivity spurt (well, the productivity will continue, but it will split among some other directions). But it was a big one, hence the need for a 7x version increment. There are two real new features here:

1) OpenID sign-in. Making the game dependent on a Google account is a bit unfair IMO, especially since creating a Google account requires a phone number these days - the anti-privacy policies really are picking up here, I'm slightly sad to see Google going this way (not to mention the inevitable secondary consequences of such actions, like discriminating against non-mobile phone users, a class which I myself was a part of until two months ago). Now you can sign in with Yahoo, Myspace and a whole host of other avant-garde technologically progressive providers!

2) The level editor. It's in the most barebones form imaginable at the moment, editing the raw code of the level (though this is an option which I'll never remove, since it allows you to keep offline copies of your work). I'll make proper documentation for this eventually, alongside my effort to supplant said documentation with a graphical editor - terrain is the first target for that, then classes, then units, then more complex events and never story since the present interface is pretty much optimal for story text already. Here's a quick tutorial - combine with the default new level to understand it.

Classes

A class description looks like this:

soldier {"side":1,"aitype":1,"damage":10,"health":90,"range":1.6,"image":"Soldier.png","speed":0.093,"desc":"","cmult":0.75,"bmult":0.6,"inacc":0}

'soldier' is the name of the class, the things in quotes are its attributes. You can see:

side - the team the class is on, the player's team is team 1, teams 0,2,4,5,6, etc are mutually hostile
aitype - 1 is player controlled, 0 is computer controlled. You can, if you want, make this 2, 3 or 4 (guard, flee, voluntary computer controlled) but if you do that the player can always overrule your decision if he decides he likes it better his way.
damage - self-explanatory
health - self-explanatory
range - number of squares the unit can hit at - 1 covers orthogonally adjacent, 1.42-1.99 all within 1 square, 2.00-2.23 a diamond going two squares out, 2.83-2.99 a square going two squares out, see here for the highly complex vector mathematics you'll need to do to make those kinds of calculations.
image - self-explanatory. Can be one of the images I use:

> ls images
Archer2.png
Archer.png
Catapult.png
Civilian.png
Dark_Knight.png
Dark_Pikeman.png
Door.png
Enemy_Archer.png
Enemy_Pikeman.png
Enemy_Soldier.png
Evil_Centos.png
Eye.png
Golem.png
grass.jpg
Guardian.png
Horseman.png
Lord_Xandros.png
Mage.png
On_The_Offensive.png
Peasant.png
Pikeman2.png
Pikeman.png
Queen_Madrina.png
rock.jpg
Soldier.png
Warlock.png
Zombie.png

or anything from any URL.

speed - self-explanatory
desc - don't worry about this yet
cmult - how much your unit slows down in combat
bmult - what speed of the maximum your unit can go backwards
inacc - inaccuracy parameter, usually set to 0 for melee, 2 for archers, 3 for catapults. Inaccurate units benefit from enfilade.

As for events, there are four types I'll introduce:

unit (class) (x) (y) - adds a unit to the coordinates. The map is 40x30.
setup (left) (top) (right) (bottom) - adds a setup rectangle. You can have multiple setup zones if you want, although units from one zone will be able to be moved into a non-adjacent setup zone at startup.
whenever AAAtBBB [any other event] - AAA ticks in and every BBB ticks thereafter, perform the event. If you make a whenever trigger a whenever, keep in mind that there are no separate timers - all time is measured relative to the beginning.
when AAAt [any other event] - the one-time equivalent.

That's it for today folks, link here: vubslasha.appspot.com as usual!

Wednesday, 24 August 2011

Version 12 up - foundation beatable, high scores!

Not as major an upgrade as 10 to 11 was, but the high scores feature has been implemented! Of the other changes that have been made, there are two categories:

Game balance:

  • effect of slopes increased by 2x, slightly more for long range units and slightly less for short range units; some existing slopes increased further. I'm seeing damage modifiers of around +/-10% for archers and +/-10% for melee (up to +/-30% on sharp slopes), which is pretty good - it means that a 10 dmg/100 hp unit could theoretically beat a 10 dmg/120hp unit with a normal slope boost and a 10 dmg/180hp unit with a sharp slope boost. Hopefully this should make strategy more interesting.
  • slight nerf to backpedaling - backward movement penalty increased from 33% to 40% default
  • A prospective change is a major rework on archers. As they stand, they are way overpowered due to the run-and-shoot functionality. I'd like the three main types to be on par, so 10 soldiers + 10 pikemen + 10 archers would come out close to 50/50 against 9 soldiers + 9 pikemen + 12 archers, but archers are way off. Obviously, pikemen are strong in groups only and archers are stronger in some situations than others, but they should not be preferred everywhere. Also, due to auto-dispersal, AI archers are actually much better than player-controlled archers against melee. The plan to implement enfilade will hopefully balance that out, making sure archers reach their full power only in well set up situations. Archer speed will probably go down too.
User interface:
  • Fixed multiple unit selection. For all this time I thought multiple unit select with shift was working fine, but it wasn't. I didn't notice since I was using my mouse. Once again this highlights the importance of testing on multiple machines.
  • Added the ability to view a summary of controls when paused.
The roadmap now, aside from the aforementioned archer changes and their fallout, is essentially the level editor. I realized that I actually need one to make and edit levels efficiently.

That's all for today!

Saturday, 20 August 2011

Foundation 1-4 beatable; preparatory reorganization; Big Brother is watching you

Realizing that I would have to do it eventually, and better now than later, I finally decided to undergo a major internal reorganization in how I store my game data (units, events, etc). Before, I used a highly inefficient format that essentially required me to write my own parser and made it a pain to write and modify levels. The source for nightfall 1, for example, looked like this:

#story This is an example campaign for Slasha 5.0. Here you will fight as a commander of Faladare against the evil wizard Xandros and his demonic minions. You first encounter the enemy near a small hill.
#setup 33.333 0 40 30
unit 0 0 10 90 1.666 Dark_Knight.png 0.093 1.333 6.666
unit 0 0 10 90 1.666 Dark_Knight.png 0.093 1.333 10
unit 0 0 10 90 1.666 Dark_Knight.png 0.093 1.333 13.333
unit 0 0 10 90 1.666 Dark_Knight.png 0.093 1.333 16.666
unit 0 0 10 90 1.666 Dark_Knight.png 0.093 1.333 20
unit 0 0 10 90 1.666 Dark_Knight.png 0.093 1.333 23.333
unit 0 0 10 90 1.666 Dark_Knight.png 0.093 1.333 26.666
unit 0 0 10 90 1.666 Dark_Knight.png 0.093 1.333 28
unit 1 1 10 90 1.666 Soldier.png 0.093 36.666 6.666
unit 1 1 10 90 1.666 Soldier.png 0.093 36.666 10
unit 1 1 10 90 1.666 Soldier.png 0.093 36.666 13.333
unit 1 1 10 90 1.666 Soldier.png 0.093 36.666 16.666
unit 1 1 10 90 1.666 Soldier.png 0.093 36.666 20
unit 1 1 10 90 1.666 Soldier.png 0.093 36.666 23.333
unit 1 1 10 90 1.666 Soldier.png 0.093 36.666 26.666
unit 1 1 10 90 1.666 Soldier.png 0.093 36.666 28

Before an earlier reorganzation it was even worse - the story text was manually split up into lines rather than it being one line and the computer splitting automatically. The problems here are obvious - extremely painful to edit, ugly, redundant. But the worst problem is that this style of data storage is contrary to how a level editor, my longest-term plan, should work - in a good level editor, you don't edit each unit's statistics individually, you create unit classes, edit class attributes and put units from those classes onto the map. Thus, I reorganized the file to look like this (just a snippet):

#setup 33.333 0 40 30
class soldier {'side':1,'aitype':1,'damage':10,'health':90,'range':1.6,'image':'Soldier.png','speed':0.093}
class darkknight {'side':0,'aitype':0,'damage':10,'health':90,'range':1.6,'image':'Dark_Knight.png','speed':0.093}
unit darkknight 1 6.666
unit darkknight 1 10
unit darkknight 1 13.333

For the class attributes, I no longer need to write a parser - it's a Javascript object already and Javascript can parse it. More reorganization is planned, but the hardest step is done - from here I can do what I need automatically with python and sed scripts.

All this means nothing to the user - it's a long term investment. Now, onto the other two parts to this update. First, foundation 1-4 are now beatable, although I have a plan in the works to make 3 more interesting. Second, there is now a feature that allows me to see the results (friendly losses, enemy losses, game time elapsed, real time elapsed) of every game you play. This is in part preparatory work for a high score table and in part so that I can balance levels better - right now, the only test subject I am getting level-specific feedback from is myself, and I have 2 years of experience playing this game and an intimate knowledge of how the AI works.

That's all for today!

Tuesday, 16 August 2011

Version 11 up - graphics upgrade, and rebellio confirmed beatable!

I've finally decided to put a bit more effort into the graphics of the game. It's never going to be anything 3D (and I don't want it to be - I don't like doing 3D stuff mainly because I don't feel like spending 100x as much time drawing), but I might as well at least push it into the 1980s :) It actually looks quite pleasant now at least in my opinion.

Game balance is a pain - I never realized just how much many of my older levels were relying on the player's vastly superior micromanagement ability, which is now inferior thanks to the version 10 AI upgrade. On some levels like rebellion 12 AI can handle almost everything better than the player! The main focus now is actually makng the player more powerful - future possibilities include nerfing backpedaling (what the AI soldiers do when you try to swarm a couple who are ahead of the rest of the group you're trying to get away from) some more, more hills and valleys for the player to exploit (or make the existing ones have more effect), and changing archer mechanics so there's more to placing them than just making sure they're in LOS (I'm thinking making archers hit all targets in a line near the target to some extent - this mirrors real-world archer functionality where you can aim directionwise just fine but targeting the right distance is a pain - see http://en.wikipedia.org/wiki/Enfilade_and_defilade ; this will require serious level rebalancing though).

Roadmap:

Short term: balancing foundation, aforementioned player buffs
Medium term (version 12): high scores
Long term (version 13 or more): a level editor

Enjoy!

Friday, 5 August 2011

Well, after nearly two years, here we are

I first started working on Slasha in December 2009. The game really started just because I had just discovered the solution to a problem that had been bugging me for years - pathfinding. Back in my days playing World of Warcraft, I always wondered what algorithms were being used to make the enemies always chase me and find me through an open field no matter how many corners I went around. The algorithm I found was just a slight modification to the solution to a simpler problem - flood filling. My solution, that had me jumping with joy at my supreme intelligence for several days straight, turned out to be the second one given on the flood filling Wikipedia article. Anyway, I decided to create a nice and simple RTS game to show off the algorithm that made it possible.


The first versions of the game were written using Python and Pygame, and were fairly slow with some fairly clunky AI. Despite this, I spent many hours making and testing campaigns for them, and slowly and incrementally improved my product. Ultimately, however, the problem is that python and pygame being dependencies and the program being a downloadable are too high barriers for me, as an amateur, to get anyone else playing the game, and I realized the hollowness of making something that only I myself had access to, and I gave up. Months followed, years followed, the soldiers of Faladare and Xandros stood there in the rain waiting for some brave general to press P (well, it was space back then) and let them go fight each other.

However, there is a happy ending. This July, I realized just how much I missed my programming hobby and got motivated to start doing something again. Thanks to Google App Engine, I realized that I would be able to publish my game on the internet. I had to rewrite everything with server side code in Python and client side in Javascript (press Ctrl+U from the game to see the client source! (BTW, I hereby release it under the public domain and if that is impossible in your country I simultaneously release it under every GPL-compatible license. Standard uppercase-letter no warranty disclaimer applies)), but the effort was worth it - Javascript turned out to be 10 times faster than Python, and I was able to make massive upgrades to the AI, to the point that I could not beat it at micromanagement. There were many upgrades, much debugging, many optimizations, I'm still not done rebalancing all the levels since the AI is so much better now (it still has a few exploitable weaknesses, of course, but far less than before) - I'm happy to report that tutorial and nightfall are confirmed beatable, though.

Me figuring out just how the pathfinding is supposed to work - bottom right shows the distance map expansion process, left shows one of my optimizations failing at going around a corner, middle is another diagram of the failing optimization, top is similar to bottom right.

Anyway, Here you go. Laugh, fail, catch an error, enjoy. And be sure to send comments back to me some way, I like feedback :)