Lachlan's misadventures in games programming

Thursday, 13 November 2014

PAX Part 2 - Games

11/13/2014 02:10:00 pm Posted by Lachlan No comments

This is Part 2 of my discussion of PAXAus. Find Part 1 here.

So - in addition to spending time seeing panels at PAX Australia, I spent a fair bit of time playing and watching various newly released and yet to be released games.

I particularly spent a fair bit of time in the extensive indie area getting to try Australian and New Zealand made indie games. It was fantastic to be able to meet indie developers - particularly those from Melbourne. As with last year, I've been struck by just how vow vibrant the indie games development community is in Melbourne.

I also had the opportunity to try a couple of new release AAA titles, and one particularly special (to me) pre-release.

Slightly off-topic - I was also struct by just how strong the Unity engine is in indie development. I knew it was strong - but I thought that the new pricing model for the Unreal Engine would have lead to more indies using it. In hindsight, I suspect that there hasn't been enough time since the pricing change, and that the Unreal engine might have a bigger showing next year.

So - following is a very brief (generally coinciding with my play time) impression of some of the things that I've played. Not everything here is by indies - but the list is heavily skewed that way

Just as a forewarning - this isn't going to critically examine and review the games I list. This is going to be a brief selection of some of the things I thought were cool, and that I think that you should check out.

Note: Release statuses are as of 12/11/2014.

Defect: the Spaceship Destruction Kit


  

 
Developer: Three Phase Interactive
Status: Unreleased
Website: http://sdkgame.com/

Defect: Starship Destruction Kit (DefectSDK) is one of those games that just seems really cool. The essence of the game is you design a starship from pieces, and then run off fighting bad guys. But then (inevitably) your crew turns on you - hence requiring you to create yourself a shiny new starship to fight your very well designed previous command - which was hopefully the subject of a well designed flaw for you to exploit. And so on, and so forth.

The guys who made it were kind of inspired by Gratuitous Space Battles (GSB) by Positech Games, and it shows. I vaguely remember Cliffski of Positech talking about the requests for a 'direct control' mode in GSB to allow you to control the ships directly rather then setting the stage for the titular gratuitous space battle. This is that game. DefectSDK shares GSB's fluid zoom and fantastic prerendered/drawn 2D artwork.

If you're a fan of Star Trek, Star Wars or the like, you should definitely check this out.

Under the Sun


  

 
Developer: Stegabyte
Status: Unreleased
Website: http://stegabyte.com/

It is fantastic to be able to go to an event like PAX and find a former classmate from High School exhibiting their soon to be released wears. Stegabyte was formed by a two man team of Tim Glew and Alex Tulloh; the latter of whom remains one of my two favourite drummers to play with (despite not having done so for a good 8 years).

Under the Sun is a self-branded '4D Puzzle Game'. The goal is to guide the protagonist to the campfire before the day is out. Each turn, the world changes both independently (such as trees growing) and in reaction to your movements. The world changing can result in being unable to make the campfire in time, and therefore the death (by old age) of the character. Fortunately, Stegabyte have made it simple to move forward and backward in time to resolve past mistakes and observe the changing world.

The artwork is fantastic, slightly dreamlike and very clear (being important in a puzzle game). The puzzles themselves are clever and ran the gamut from easy to more difficult then I could complete in the time I had. My understanding is that is to be released on Windows, iOS and Android.

I'm looking forward to its release.

Screen Cheat


  

 
Developer/Publisher: Samurai Punk/Surprise Attack Games
Status: Released on Steam
Website: http://screencheat.com/

This has already been released, so you might already know something about it. I was fortunate enough to have a couple of rounds with friends and strangers.

(Cue annoying infomercial voice)
Have you ever been told off for looking at the other players screens when playing Goldeney or Perfect Dark?
Have you been accused of playing unfairly, maybe even cheating?
Have you had your defense that 'everybody can do it!' and potentially your argument over the prisoners dilemma thrown out without a consideration?

If so, Screencheat is for you and your friends!
(Yeah - that's enough of that)

So - the concept of Screencheat is that it's a first person shooter where all of the players are invisible. You must look at the other players screens to be able to discern their location, in order to pulverize them with projectiles. It's a fantastic concept, and very well executed.

The levels are really well designed for this specific game. They are divided with very clear coloured sections so even an amateur can get a rough idea of where another player is looking, or at the very least whether they are in the same room. I see this becoming a really competitive game when you know the layouts of the level.

Coming from a traditional FPS paradigm, it is fairly difficult to be able to hit other players. It is still difficult to figure out exactly where somebody is as opposed to where they are looking. However, the hit-boxes seem wide enough to accommodate the gameplay.

This is a good concept, well executed. I really hope that they'll be selling cosmetic DLC for the characters.

Rogue Singularity


  

   
Developer: Considerable Content
Status: Not yet released
Website: http://www.roguesingularity.com/

I didn't get around to actually playing Rogue Singularity but I spoke for some time to the developer and watched a bit of it being played. So I can't really comment on the gameplay beyond the obvious (that it's a 3rd person platforming game). The platforming looks clean and fluid with a double jump mechanic.

The reason I'm interested is because (like most games bearing the name 'Rogue') it is procedurally generated. Each level you play will be created by the computer - much like in Atlas Warriors. Unlike Atlas Warriors, this looks fantastic and generates really interesting 3D levels.

It also looks really, really good. The Skyboxes are a very high quality and look fantastic. The levels themselves look clean and good.

I'm interested to see how this ones turns out.

Crawl


  

  

Developer: Powerhoof
Status: Released (Early Access) on Steam and Humble Store
Website: http://www.powerhoof.com/crawl/

I didn't get a chance to play Crawl at PAX (although it was there) but I heard lots of people talking about it - including one friend who has purchased himself a copy. It has been described by the developer as a dungeon crawler where your friends become the monsters,

At any time, one of the players is controlling a hero, whilst the other players try to kill them. When they do, that player become the hero. The other players control ghosts that can effect the world, either directly (by producing weird ectoplasm blob balls), by inhabiting deadly traps or by incarnating as monsters. At the end of each level, the players get to u

pgrade their monsters. The hero can use the gold they gain by killing to purchase new weapons and spells to attack the monsters.

The ultimate goal is for a player to get above level 10 (as a hero) and go through a portal to fight a boss monster (again, controlled by the other players). At the moment, there is only one boss monster - but this will be improved soon.

All this wrapped up with some procedural generation of levels and really cool pixel art and retro styled graphics.

It is currently $9.99 on Steam, and a lot of fun for some local multiplayer action. I recommend you give it a look.

Appointment with Fear


  


  
Developer: Tin Man Games
Status: Released on Steam, Google Play and iTunes
Website: http://fightingfantasyapps.com/books/appointment-with-f-e-a-r/

Again, I didn't get the chance to play this at PAX, but I was fortunate enough to get steam code for it (and have subsequently purchased the Android version).

I really wish that I knew how to define Appointment with FEAR as it seems to defy genre. It is somewhat like interactive fiction with a fantastic silver-age of comics theme (with the fantastic spinny Batman style animation between some dialogues!).

You follow the hero from a second person point of view ('You ... ') being told what's happening. You then get given a list of options you can take. You work Titan City as a hero, collecting clues and stopping crimes whilst trying to hold a day job as a reporter.

The combat works well and consistently for the style of game. The artwork is charming and exceedingly well drawn (as you can see from the screenshots). The writing is excellent.

It's not a huge investments ($5.99 on Steam, $2.99 on Android/iOS). I've already recommended it to one superhero loving friend, and I'll probably recommend it to some more. I will note that it feels better on the tablet with touch screen controls then on the Desktop - so I particularly recommend the Android version.

Sentinel Tactics: The Flame of Freedom

Developer: Greater Than Games
Status: Released
Website: http://sentineltactics.com/

This is the only board game to make this list. I spent more time checking out new video games then board games (although I played a couple of other board games with friends while there). I was keen to try this, as I am already a fan of the Sentinels of the Multiverse. For clarity, I'll refer to the two games as Tactics and Multiverse.

I played Multiverse at PAXAus last year, and promptly went out and ordered myself a copy, and now have all the expansions so far released. Multiverse is a cooperative silver-age of comic books themed card game where you play the Sentinels against a variety of villains in a variety of settings. The heroes, villains and settings all belong to a fictional comic Multiverse inspired very closely by DC and Marvel heroes, villains and settings. The cards have fantastic drawn art and quotations from the fictional comic books. One of the few characteristics that makes it feel different to most superhero games is that you always feel like you're on the back foot, and every fight could be won or lost right until the end.

Sentinels Tactics manages to take a similar feel and turn it into a tactical board game. There are fairly simple rules (like Multiverse) and cards and heroes that allow you to tactically and strategically bend those rules (again, like Multiverse). Unlike Multiverse, the PvP elements reward knowing the actions that your enemy may take a lot more. The PvP elements also mean that you must consider the actions of the other players rather then merely the chance of a horrific villain card coming up. The board game elements also add an element of location that distinguishes it from the card games and means that some heroes (particularly the Flash analogue - Tachyon) actually feel like their powers feel different to the other heroes.

If you're a board gamey or superhero fan, this is worth giving a look - particularly if you're a fan of the original card game.

Mortal Kombat


 


 
Developer/Publisher: Netherrealm/Warner Bros Interactive
Status: Unreleased
Website: http://www.themortalkombat.com/

So - more disklosures: I've loved Mortal Kombat for a really long time (as can be evidenced by my kopy of Mortal Kombat II for the SNES, piktured on this years PAX scarf below).
My own beloved kopy of Mortal Kombat II for SNES
So - the chance to play a brand new Mortal Kombat game, 6 or so months before release was absolutely fantastik for me.

I'd like to take a brief moment to talk about how major Mortal Kombat been shown at PAXAus, before release is. The last Mortal Kombat game (which, for the record had fantastic kombat, and awful plot) was only released in Australia last year due to having been blocked from the Australian market entirely due to Australia lacking an R rating. That has all changed, and that is fantastik.

Mortal Kombat is an interesting beast. It has always distinguished itself to the publik from its kounterparts (most notably Street Fighter) by being a lot gorier and bloodier. To me, it distinguishes itself from its kounterparts (again, most notably Street Fighter) by the fluidness and ease of its kombat. Where games like Street Fighter make the very act of performing a highler level move diffikult, Mortal Kombat makes it easy to do the moves but still requires timing and strategy as to when, and how to block them.

I only had one fight (Sub-zero -v- Raiden) but learnt enough to say that the kombat looks and feels fantastic. The combat with sword type attacks feel a little more visceral then they did in 9. I'm glad to see the returns of 9's fantastic x-ray moves. Unfortunately, I didn't get a chance to see any Fatalities, but they're already on YouTube.

I wish I had a bit longer to get more impressions and more detailed information, but what I had leaves me really excited for X.

Sunset Overdrive



 



 
Developer/Publisher: Insomniac Games/Microsoft Publishing
Status: Released on Xbox One
Website: https://insomniacgames.com/games/sunset-overdrive/

Unfortunately, I only had a single game of Sunset Overdrive but it was a lot of fun. It's essentially a third person coop arena shooter against waves (kinda like Mann v Machine in Team Fortress 2). It's got very cool Bioshock Infinitesque movement along sky cables/power cabled. It's got good fluid combat with a wide variety of guns with very different effects.

It looks good, and feels good. But honestly - it won't (by itself) sell me on getting an Xbox One.

So - that's it for Part 2 on my series on PAX. Part 3 will be coming soon, and will have a conversation about what else I managed to do at PAX and why I think that PAX is so important, and why I was so sad for it to be finished.

Feel welcome to share any views on anything you played or the games I've discussed in the comments below.

Saturday, 8 November 2014

Atlas Warriors Alpha 2 Released

11/08/2014 12:45:00 am Posted by Lachlan No comments

I've released the second alpha of Atlas Warriors on Github. You can get it on https://github.com/lkingsford/AtlasWarriors/releases/tag/alpha-002 for Windows.

Again, please provide any feedback you have.
Tell me what you like about my game, and tell me what is horribly wrong. There is an issue tracker for bugs and the like on https://github.com/lkingsford/AtlasWarriors/issues. Could you please report any minor or (far more importantly) major bugs that pop up?

If it is your first time playing, I recommend you have a look at the weapon summary here to understand how the different weapons worth. Providing an in-game explanation is a high priority.

Potentially incomplete list of changes:
- Added messages dialog
- Modified inventory and load out dialog
- Turned off cheats by default
- Added 'support' link to main menu
- Added support for image backgrounds
- Other bugfixes including (but not limited to)
- Closing issue #7
- Closing issue #6
- Closing issue #4
- Balance changes including
- Altering difficulty of Goliaths
- Altering difficulty of final level depending on difficulty chosen)

Good luck

Thursday, 6 November 2014

Graphical Upgrades for Atlas Warriors

11/06/2014 05:35:00 pm Posted by Lachlan No comments
I've been considering ways to make Atlas Warriors look a little bit better. One approach I'm trying is to display image background behind the playing field.

I think that the effect is striking, but has the potential to be problematic.

I think that I might make them toggleable, and I think that they need further work. For instance, I think that most are a little too bright (hence why I've added the shadows to the letters). I'm interested in your thoughts on whether this is a good idea or should be abandoned. You can click on the images for a closer look.

I can be fairly certain that they'll at least be in the next release.

      

I've also been working on improving the state of the dialog boxes. I've added a basic messages dialog. I've improved the inventory dialog (most notably by adding a 'floor' part - the former only way of picking something up was by walking on it). Finally, I've made the skills a bit tighter. Again, these will all be in the next release.

  


If you're OK dealing with source code or running python scripts, you can get the updates now from Github. You'll need Python 3.3 and Pygame installed. Otherwise, they'll be another release within the week.

Tuesday, 4 November 2014

PAX Aus Part 1 - Panels

11/04/2014 11:20:00 pm Posted by Lachlan No comments

I have spent the last weekend (being 31 October, 1 November and 2 November 2014) at PAX Aus. This is an overly long post, so I'm going to break it into probably 3 parts.

If you have never heard of PAX, PAX (Penny Arcade Expo) is a huge gaming convention run by the guys who make Penny Arcade. PAX started in US, and has since expanded to include 3 conventions spread over the US, and a convention in Melbourne, Australia. PAX Aus only started last year. PAX is specifically a gaming convention for all types of games. It has exhibits and playing areas for Computer Games, Console Games, Board Games, Collectable Card Games, Miniature War Games and Role-playing games (both Pen and Paper and Live Action), It has a series of talks over the weekend by influential personalities in the gaming industry and people with interesting things to discuss.

It was a fantastic and wonderful weekend. I want to spend some time and discuss what some of the highlights of the convention were for me. I also want to discuss a little about identity as a gamer and why I am so sad for PAX Aus to be finished.

Over my weekend I attended 5 talks and panels. I saw the first Q&A with Mike and Jerry (the creators of Penny Arcade) and the Draw a Comic! with Mike and Jerry. As was expected, both were absolutely hilarious. As was less expected, both were so encouragingly gracious about how successful PAX was in Australia and how they are able to do what they do as profession. Mike and Jerry are, for all intents and purposes, the rock stars that attend PAX and accordingly enter with huge flashing lights and the speakers blaring 'Every Day I'm Hustling'. 

I attended a DIY Indie Games Panel featuring a group of indie game designers who have extensive experience doing everything themselves. For me particularly, it was fantastic to discover the Melbourne based interactive composer Maize Wallin. It opened my eyes a bit on perhaps where I should be more focusing my game efforts in the future, given my extensive experience as a musician. If you are interested in interactive sound and music installations, I would encourage you to check out her website. I really hope to having an ongoing conversation with her.

I attended a Game Design Live! workshop with another group of local designers and Ron Gilbert (of Monkey Island fame). The talk was certainly interesting, but was a little let down by the ultimate choice of design as per the fate of a series of unlucky D20 rolls that, if in a game of D&D would likely result in the entire party being hung, drawn, quartered, cursed and doomed to eternal damnation. The task was to write a design document for a Ant-Themed Bureaucracy Game, starring a Hotel Receptionist and the theme of Hope. Some parts of the design process were enlightening, but the end design document is likely to be unusable. It is to be released to be freely available, and I will link to it when I find it.

The final panel I attended was a fascinating discussion on spirituality in videogames. It featured Jason Imms, Mark Serrels, Patrick Stafford and Nathan Cocks. It started with the byline 'Why do all religious-themed video games suck so badly'? Some of the conclusions reached seem to be aimed around the fact the religious-themed games seem to have the intent to teach and convert rather then being good art. Examples were drawn from historical (non video game) art as part of a discussion whether both were possible. There was also an extensive discussion on how effective spiritual themes can be as part of a game - whether specific to a faith, or at least discussing religious themes. The examples included Journey (which I have unfortunately not played). I might try to digitise my notes on this talk at a later date and continue the discussion a little more.

I would be really interested to hear any thoughts that you have on the subject - feel welcome to comment on them or send me an email to lachlan@nerdygentleman.com. Also - feel welcome to share your experiences with PAX: I'd love to hear about it.

Coming in Part 2 - The games I played and saw. Find Part 2 here.

Friday, 24 October 2014

Atlas Warriors, First Alpha Pre-Release

10/24/2014 04:57:00 pm Posted by Lachlan No comments
Tl;dr - First prerelease of Atlas Warriors is out, download from https://github.com/lkingsford/AtlasWarriors/releases. It's not quite finished yet.

I've opened up access to the first public pre-release of Atlas Warriors!

It is not finished yet, and shouldn't be considered to be so. There are still features missing (some minor, some glaring) and still some bugs that need fixing (again, some minor and some glaring). But it is playable, (theoretically) winnable and sometimes even fun.

But I really want to emphasise that it is still a work in progress. It still needs more stuff done before I will even consider moving it to Beta.

I finally wanted to get some feedback on how playable it is before starting to move on to attempting to balance the beast. So please - feedback away! Tell me what you like about my game, and tell me what is horribly wrong. There is an issue tracker for bugs and the like on https://github.com/lkingsford/AtlasWarriors/issues. Could you please report any minor or (far more importantly) major bugs that pop up?

You can download it from https://github.com/lkingsford/AtlasWarriors/releases. At the moment, I've only got a Windows 64 bit binary there (so if it doesn't work, that might be why).

You can also get the source from there. It's under an MIT license, so it's fairly open slather what you can do it. If you're running linux, you should be able to play it from source with Python 3.3 and Pygame. It's rl.py that contains the game proper.

If you'd like to support development financially, you can do so on https://pledgie.com/campaigns/27179 or by bitcoin (eek!) sent to 14PgnsEcgqgSrCFxTjVvczfu5Fyh85hjbU (barcode at the end of the post).

I don't think I've made it clear inside the game how some of the weapons work (although you should be able to figure it out fairly quickly). I recommend having a quick look at my previous post (http://www.nerdygentleman.com/2014/10/on-weapons.html) for a bit of a hint. You might also find the descriptions of the monsters on (http://www.nerdygentleman.com/2014/10/meet-monsters.html) to be helpful.

I'm not sure what else to say, so good luck (to both of us...)


Lachlan


PS - Bitcoin Donations - 
Bitcoin donations - to 14PgnsEcgqgSrCFxTjVvczfu5Fyh85hjbU

Tuesday, 7 October 2014

On Weapons

10/07/2014 01:38:00 pm Posted by Lachlan No comments

I have a similar philosophy for this game with weapons in that each weapon class needs to have a unique purpose. Although unlike monsters, I'm very willing to allow weapons to be incremental upgrades of other weapons.

The Weapon Classes will play differently, very inspired by Brogue. We have:

  • Daggers - You get a free counterattack when you are attacked and hit.
  • Swords - Blocking a hit with a sword allows you to parry, effectively attacking the monster.
  • Polearms - Polearms can attack two monsters in a row. At the moment, this only works when one monster is adjacent to you. I'm considering whether or not this should chance.
  • Axes - Axes are slow, but attack in a 90 degree arc. 
  • Blunt - Blunt weapons will stun any monster for one turn, if they hit.
This will hopefully provide some interesting gameplay opportunities.

Sunday, 5 October 2014

Meet the Monsters

10/05/2014 12:45:00 pm Posted by Lachlan 1 comment

My design philosophy (as much as I've had one) for Atlas Warriors is that everything has to have purpose. There is no need on having two different monsters that perform the same function and gameplay.

In order to do this, I do have different levels of some monsters - so (for instance) you can find Bandits, Experienced Bandits, Veteran Bandits and (hopefully never in a promising game) Bandit Warlords. Bandits are unique in being Melee characters who use weapons. There is no need to have another monster just to add a different letter and colour that does the exact same thing just may be a little harder.

As such, there are a small amount of monsters in Atlas Warriors - but they all provide a different experience.

We have (in order of appearance):

Critters - Cute. Furry. Fanged. Clawed. Actually - forget the Cute. They blindly move towards the player and attack them. Usually pretty weak.

Bandits - Men and woman who have dedicated themselves to causing crime for self interests sake. They seek out the player (and are clever enough to find the player rather then just wander in their direction), and attack the player with weapons. They get the same type of weapon effects that the player does.

Orcs - Archers from a foreign land. Orcs are reasonably strong, and have a melee attack but specialise in shooting you from afar.

Goliaths - Big. Gigantic. Brute. These horrors of gargantuan proportions are slow as they are dumb - but they can hit like a tonne of bricks and charge. They have no definition of friend or foe - they mercilessly kill anything in the dungeon and get stronger in the process.

Assassins - You think you see a shadow in the corner of the room. As soon as you turn to look at it, it's gone. You don't even feel the blade between your ribs until it is too late. Unless you are adjacent to them, Assassins are invisible when directly next to a wall or door. They've got low health, but a deadly strike.

Drakes - If it weren't for the stench of sulfur and smoke, you might consider that this midget dragon was almost cute. These breathe fire at you, and can set you alight.

Zombies - You smell the rotting flesh before you see a long dead corpse with the mission to kill. Zombies are fairly weak and have a weak attack. However, each adjacent Zombie reduces your defence significantly. Strength in numbers!

Necromancer - The first subboss. He may be skippable - if you're lucky. Raises Zombies. (I may also give him a bolt attack)

True Dragon - The second subboss. He may be skippable, but killing him will guarantee a very nice reward. This is almost the exception to my minimalism, as it really is a far stronger version of a drake. The True Drgaon will gratuitously provide rolling flames of swift death.

Final Boss - To be determined.

Friday, 3 October 2014

The Tomb of the Necromancer

10/03/2014 12:07:00 pm Posted by Lachlan No comments
I've spent the last few days redoing the monster-generation for levels. It's working reasonably well.

One of the things I've decided is to include a special undead level - the Tomb of the Necromancer. The Tomb of the Necromancer includes the titular Necromancer and Zombies. It's a regularly patterned level with lots of doors that will hopefully have players surrounded and be a sufficiently horrifying and memorable experience.





Zombies are going to be reasonably weak, but they're going to reduce your defense significantly when they're adjacent to you. You won't want too many nearby, or else you're going to be taking a lot more damage and dying a lot sooner.

Sunday, 7 September 2014

A* Pathfinding in Python

9/07/2014 03:12:00 am Posted by Lachlan , No comments
I thought the following might be helpful to some of you. It's a snippet of code in Python to perform A* Pathfinding.

I've been avoiding writing it for ages, but have been yet again impressed by how little Python gets in the way of what I'm doing. I remain impressed by the language.

Again, method was found on http://www.policyalmanac.org/games/aStarTutorial.htm

It's reasonably well commented, and should slot it fairly easily into any grid-based environment. It doesn't support weighting yet - but it would be trivial to add (include the weight when adding distance for g).

I apologise for my inconsistent naming conventions. I started the project with no idea about Python, and the A* had to fit into that dodgy area. Essentially, you'll have to replace self.x and self.y with the starting potion and replace reference to self.currentMap.Walkable with where to get a boolean value of the walkability of the position.

And again, this is released under my modified UnLicense:
Lachlan's Very Public Licence - which is a slightly modified Unlicense
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.
In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law.
If you use the source, the Author (Lachlan Kingsford) would actually like to know - but it's by no means necessary. Feel welcome to provide a copy of what you do via email, or comment on www.nerdygentleman.com. Attribution is also nice and appreciated, but again, by no means necessary. Donations via paypal are also nice.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


    def GetRoute(self, dest):
        # Performs an A* search to find route to go somewhere
        # Input:
        #   x, y - from self.x and self.y
        #   self.currentMap.Walkable(x,y) - returns if can walk at x,y
        #   dest - (x, y) tuplet of destination
        #
        # Returns a list of (x, y) tuplets
        # 
        # From <http://www.policyalmanac.org/games/aStarTutorial.htm>
        # 1) Add the starting square (or node) to the open list.
        # 2) Repeat the following:
        #   a) Look for the lowest F cost square on the open list. We refer to this as the current square.
        #   b) Switch it to the closed list.
        #   c) For each of the 8 squares adjacent to this current square 
        #      If it is not walkable or if it is on the closed list, ignore it. Otherwise do the following.           
        #      If it isn't on the open list, add it to the open list. Make the current square the parent of this square. Record the F, G, and H costs of the square. 
        #      If it is on the open list already, check to see if this path to that square is better, using G cost as the measure. A lower G cost means that this is a better path. If so, change the parent of the square to the current square, and recalculate the G and F scores of the square. If you are keeping your open list sorted by F score, you may need to resort the list to account for the change.
        #   d) Stop when you:
        #      Add the target square to the closed list, in which case the path has been found (see note below), or
        #      Fail to find the target square, and the open list is empty. In this case, there is no path.   
        # 3) Save the path. Working backwards from the target square, go from each square to its parent square until you reach the starting square. That is your path.
        
        # ORTH_DISTANCE and DIAG_DISTANCE are for weights of travelling between the cells orthogonally
        # and diagonally respectively. If diagoanal is further in game, then DIAG_DISTANCE should be 14
        # As the distances are the same in mine, they're weighted evenly
        ORTH_DISTANCE = 10
        DIAG_DISTANCE = 10
        
        # Heuristic for calculating h is Manhattan Distance - 
        #   abs(pos.x - dest.x) + abs(pos.y - dest.y)
        
        # OpenLists consists of tuplets with (
        #   [0]: Position.x, 
        #   [1]: Position.y,
        #   [2]: ParentPosition.x, 
        #   [3]: ParentPosition.y,
        #   [4]: g (distance to get here from parent),
        #   [5]: h (heuristic distance to destination) )
        OpenList = [(self.x, self.y, self.x, self.y, 0, abs(self.x-dest[0]) + abs(self.y-dest[1]))]     
        ClosedList = []
        while (len(OpenList) > 0 and (len([k for k in OpenList if k[0] == dest[0] and k[1] == dest[1]]) == 0)):             
            # Find entry in OpenList with lowest F score
            # F = G + H                     
            Current = min(OpenList, key=lambda i:i[4]+i[5])         
            OpenList.remove(Current)
            ClosedList.append(Current)
            Active = [(Current[0] - 1,  Current[1],     Current[0], Current[1], Current[4] + ORTH_DISTANCE, abs(Current[0] - 1 - dest[0])   + abs(Current[1] - dest[1])),
                (Current[0] + 1,    Current[1],     Current[0], Current[1], Current[4] + ORTH_DISTANCE, abs(Current[0] + 1 - dest[0])   + abs(Current[1] - dest[1])),
                (Current[0] - 1,    Current[1] - 1, Current[0], Current[1], Current[4] + DIAG_DISTANCE, abs(Current[0] - 1 - dest[0])   + abs(Current[1] - 1 - dest[1])),
                (Current[0] + 1,    Current[1] - 1, Current[0], Current[1], Current[4] + DIAG_DISTANCE, abs(Current[0] + 1 - dest[0])   + abs(Current[1] - 1 - dest[1])),
                (Current[0] - 1,    Current[1] + 1, Current[0], Current[1], Current[4] + DIAG_DISTANCE, abs(Current[0] - 1 - dest[0])   + abs(Current[1] + 1 - dest[1])),
                (Current[0] + 1,    Current[1] + 1, Current[0], Current[1], Current[4] + DIAG_DISTANCE, abs(Current[0] + 1 - dest[0])   + abs(Current[1] + 1 - dest[1])),
                (Current[0],        Current[1] - 1, Current[0], Current[1], Current[4] + ORTH_DISTANCE, abs(Current[0] - dest[0])       + abs(Current[1] - dest[1] - 1)),
                (Current[0],        Current[1] + 1, Current[0], Current[1], Current[4] + ORTH_DISTANCE, abs(Current[0] + dest[0])       + abs(Current[1] - dest[1] + 1))]
            for i in Active:
                # If point not in closed list and is walkable
                if (len([j for j in ClosedList if j[0] == i[0] and j[1] == i[1]]) == 0) and self.currentMap.Walkable(i, True):
                    # Look for point in open List
                    Candidate = [j for j in OpenList if j[0] == i[0] and j[1] == i[1]]
                    # If point not in open list                 
                    if(len(Candidate) == 0):
                        # Add point to the open list
                        OpenList.append(i)
                    else:
                        # Otherwise, check to see if this path to the square is shorter, using G. If so, replace square with current route (changing parent and g) 
                        if Candidate[0][4] > i[4]:
                            OpenList.remove(Candidate[0])
                            OpenList.append(i)
                
        # If no path found, return empty route
        if len([k for k in OpenList if k[0] == dest[0] and k[1] == dest[1]]) == 0:
            return []
        else:
            # Add path to route
            Route = []  
            CurSquare = [j for j in OpenList if j[0] == dest[0] and j[1] == dest[1]][0]
            # Iterate until we reach the starting point
            while (not(CurSquare[0] == CurSquare[2] and CurSquare[1] == CurSquare[3])):                 
                CurSquare = [j for j in (OpenList+ClosedList) if j[0] == CurSquare[2] and j[1] == CurSquare[3]][0]
                Route.insert(0, CurSquare)
            return Route