Showing posts with label AI. Show all posts
Showing posts with label AI. Show all posts

Tuesday, September 26, 2017

Update 51: Emerging AI

Next on the list was AI. I had a plan for this. Since most interactions are over in 2-3 turns, I don't think I have to worry about a higher AI (where the AI is trying to think long term). I think, (at least initially), I just want to encourage the AI to move towards the player and be fairly aggressive, staying in cover and shooting if the chance to hit is high. These ten rules are definitely just a starting point.

  1. Find all possible tiles the character can move to, initializing them with a score of 0.
  2. Assign points to any tiles that are in cover (+10). If the character is currently not in cover, give all of those positions an extra boost to encourage the character to move into cover. (+10)
  3. Add points for tiles that are in range for the character to shoot at the opponent. (+10)
  4. Add points for tiles that close the gap between the AI and opponent. (+5)
  5. Add points for positions in cover that flank the opponent (+20)
  6. Add points if the opponent is within range and has more than a 50% chance to hit. (+10)
  7. Add even more points if the chance to hit is 80% or more. (+20)
  8. Add even more points if the chance to hit is 95% or higher. (+30)
  9. Order the list by total score, descending order (highest first)
  10. Pick the top score from the list. 

When I add difficulty levels later, I will randomize the top 3-5 scores and pick one. This will help to give the AI some unpredictability and ensure that it's not always brutally taking the best position. Everyone makes mistakes, and it's important the AI does too (except on maybe the highest difficulty level). I may do this sooner than later to keep things interesting.

This AI is currently working, but I have some timing issues, where the AI moves into cover, but fires his weapon for his second action before he has completed his first action. 

Here is a series of screenshots showing the AI's at the beginning of a turn (standing out of cover), and then moving to cover and shooting at the (flanked) player. 

This one is showing the timing issues I have, where the AI fired (action 2) before completing his walk to the new cover (action 1), in the process destroying the cover.




Next I'm going to tweak the timings so the actions are one at a time and add side steps to the characters so that when behind cover they don't shoot out their own cover, but step to the side and shoot around the cover.

Friday, October 17, 2014

Update 39: Exploring Pathfinding

Another week, another round of bugs fixed.

  • Added some basic sounds for explosions and shooting
  • Fixed some bugs around shooting when I missed. The bullet would stop at the target, instead of continuing into the sunset. 
  • Upgraded the shooting range modifier using the formula:
    • RangeModifier = 50 - ([tiles between source & target * 5)
  • Upgraded the AI to choose the best target based on the difficulty, instead of taking the first enemy off the list
  • Started work on creating a path finding solution. I'm using the Aron A* Pathfinding Project. You can see an early prototype below. The first screenshot shows no smoothing, the second with smoothing.




Friday, May 9, 2014

Update 34: The AI is playing itself and the beginnings of a campaign.

Accomplishments this week:


AI: One of my next tasks was to apply the AI to both teams of the tactical game. While I wait for Unity 4.6's new UI to be released, using AI on both sides allows me to ignore the UI and refine the AI code. This also has the positive side-effect of preparing the AI to work better in multi-player games. This also includes selecting, targeting and dead (smoldering) tank animations. You can see these below.



Campaign: Moving next to the campaign, my goal was to create a very simple UI where:

  • Time would pass
  • Enemy encounters would be spawned
  • The game would load the tactical level with the right players and enemies
  • Auto resolve the battle with the AI
  • Return back to the campaign, where the players would receive experience and abilities as they level up.


I had to fix a lot of bugs with the AI and camera to make this all work, including creating a new static game object, but it all works great.

What is next:


  • Game Balance: The tactical game isn't currently very fair 
  • Refining the character sheet: I need to add some new properties to the characters that I am now using
  • Adding in the Campaign Diorama
  • Adding objects to the tactical game
  • Leveling up the tanks: Character progression is very important to this game

Friday, February 14, 2014

Update 30: Line of Sight

I've managed to implement a simple line of sight mechanic with ray casting. If my character can't see an enemy - because they are behind another object and therefore, not in 'line of sight' of my character, I hide the mesh renderer on the object, effectively making it invisible. 




The great part about this solution is that the enemy character is still there and it's AI is still running. When the enemy character comes back into view again, I just enable the mesh renderer. Every time a character moves, I ray cast between each character and enemy to see if they are visible and then hide and show the enemy character depending on if they are in the line of sight of my player.

Here is a sample where I can't see the enemy (although, because I haven't yet replaced the UI of the enemy characters, you can see their health bars - this will be fixed later):




And here, after I move around the obstacle, I can see the enemy character again.



Sunday, October 13, 2013

Update 23: Alpha 1.6 - Lots of stuff finally released!

Alpha 1.6 has been released. This represents about 10 months of (part time) development, and is finally a little mini game. Admittedly a game without much depth, but still a game! Included in this release (since Alpha 1.5) are:

  • New cameras
  • Timing fixes all over
  • A very basic AI
  • New character models and animations
  • More dynamic explosions
  • Targeting indicators
  • More advanced stress testing
  • Links to the currently active test levels
  • And lots of little bug fixes


This is all pretty exciting to me, and I've started working on a story/theme for the next step, while I also add in some feature requests and refine some of the mechanics a little.

Try it out for yourself and let me know what you think!



Friday, October 11, 2013

Update 22: Alpha 1.59 - Cameras

I was so close to releasing Alpha 1.6, but at the last moment I had to postpone due to camera issues that forced me to spend an extra week rewriting the camera mechanics. I'm close, the camera now pans, rotates and zooms with just a few issues left on some of the camera position calculations for the AI.




It's all good though, the new characters look great and the AI is also progressing nicely. It's so close to a game now! I'm hoping to release Alpha 1.6 by Monday.