Legend Bowl’s AI Engine Past, Present and Future

The past couple of weeks have been extremely busy and arduous, to say the least.  As I’m rebuilding Legend Bowl from the ground up, I’ve set a priority on gameplay and building a robust artificial intellligence (AI) engine as its foundation.

Steering Behaviors

Let’s talk about AI and what it means to a video game as complicated as sports and a sport such as football to be exact. There are various concepts out there when it comes to AI in games, but the one that stands out the most is a concept called “Steering Behaviors” developed by a fellow named Craig Reynolds.  Just google it and you’ll find thousands of interesting articles and videos describing these concepts and how much power they can have on your game while eliminating much of the overhead used in complex AI systems.

Seek and Flee
Seeking behavior is the core of steering behaviors
Pursue and Evade
Pursuing objects intelligently

My previous build of Legend Bowl included these steering behaviors as the core movement system throughout the entire engine.  As I moved further into the development of the game, I began to notice weird behaviors coming from my agents.  For example, there would be oscillation when a player was flipping back and forth while deciding on what direction to move in next.

Crowd Path Following
Crowd Avoidance Simulation

Another issue was related to the positioning of players and many times players would get locked up when trying to move to a location as other players were blocking their path.  There were several other issues I won’t bore you with in this blog, but needless to say the AI system just wasn’t organic and cleanly enough for a complicated sport such as football and I knew I needed something better to take its place.

My “Home Grown” AI System

My intial approach was to try and build my own “home grown” AI system for a ball returner to see if that would be any better.  You can see that in the image below where I was creating a rectangle that turned at the same angle the player was turning and then would check for collisions to avoid tacklers.

02.06.2019-12.35.49

Then I moved on from making my own custom rectangle/box collision system using vectors and points to something a member of the GMS2 community created for these types of wide-range collisions. This was great because you could easily change the dimensions of the rectangle collision object to your liking and anything that would collide to it would be detected without needing to code up a sophisticated system to detect all of these collisions.

The overhead of creating “raycast” lasers to check every point would bring any game to a crawl and this seemed like a creative solution to try out in Legend Bowl.

Even though this was an improvement from both a performance perspective, but also was robust enough to use everywhere it still seemed like I needed more.

Context Map Behaviors

Fast forwarded 6 plus months later and now being back on Legend Bowl I began to research how to fix some of the AI issues I was experiencing.  As I was looking through articles, I ran into a concept I once heard of while researching Steering Behaviors called, “Context Map” behaviors which seemed to simplify the process and think of decision-making AI as something less complicated, but gave the power and organic nature of a real human decision making system.

Context Map Interest vs. Danger decision slots

All of this research lead me to a man by the name of Andrew Fray, who’s an AI engineer on several AAA game titles, but notaby for F1 racing.  I believe he came up with this AI concept and shows how powerful it can be when used for agents making decisions in a crowded space where steering behaviors could not cut it.  He has some articles explaining Context Behaviors on his website if you wish to read in more detail and also did a GDC presentation in 2013 about AI and goes in depth on the system.

GDC AI Summit Presentation – Andrew Fray

The concept just blew my mind and made it crystal clear that this was the choice for Legend Bowl’s AI system.  So without much hesitation, I began the process of building a prototype of the AI using Game Maker Studio 2.

Let’s just say I had MANY questions on how to accomplish his simple, yet very complex theory.  One question was how to determine the number of “antennas” as I like to call them would serve my game.  Another was how the hell to code this and make it morph into what I need.  So I rolled up my sleeves and began typing away, while researching more on the topic and getting as familiar with it as I possible could.  I quickly began to put things together and found another article by James Keats who did this for a school project.   This is where I could test the AI out using his demo to get a feel for what I could build in GMS2… that’s why they look so familiar!

Even though I had something I could tinker around with and play, it still wasn’t enough to show me how to “code” it into my engine.  He didn’t share much code and there were still many gray areas I was missing.  Long story short, I pounded my way through it and finished my first prototype somehow.

Legend Bowl AI Prototype

My plan to develop a prototype was to start up a clean empty GameMaker Studio 2 project and build the context behavior AI for a ball carrier.  I started out with building the lists to hold the various danger and interest spots for each player.  Then I moved on into building the script to evaluate the closest danger players in 8 directions and rank them in some sort of weighted scale.

Example of Context Map used for 8 directions

The next step was to grab the closest interest object and move away from the most prominent danger directions to come up with a final direction to pursue.  This was all hardcoded to 8 directions and after several attempts and tweaking I was able to get something that started to look like a football player running with the ball, while avoiding tacklers!

Early prototypes below illustrate the player arrow moving towards the green interest objects and trying to avoid the red danger objects.

The next steps were to tune and tweak the logic so the player could see further and adjust to danger in a more realistic fashion.  I also began adding more realistic danger objects to see if the player could sift through the field without getting touched by defenders.

The final step in the prototype was to refactor it so I coudl dynamically adjust the number of directions for testing when I ported it over into Legend Bowl.  It took me a full day or so, but I was able to reduce the number of lines of code by 70% while adding a much more dynamic system that could expand and collapse to whatever number of directions needed for testing.

Increasing the number of “antennas” as I like to call them really didn’t always make for much of an improvement and in some cases made the players try to “squeeze” through too small of holes, instead of going around the crowd of defenders.  Although it was nice to have the option of allowing less or more paths for the player to take depending on the situation.

In summary, Context Map Behaviors started to feel like the obvious choice based on my prototypes.  I was really happy with the results, but wasn’t sure how well they would translate into the actual game.

In the next blog post, I’ll share how all of this prototyping and testing made its way into Legend Bowl.  Thanks for reading and stay tuned for more news and information in the coming weeks!

Download the demo:  Context Behaviors Demo

Be sure to join the Discord server for the latest!

Indie Game Devlog #16 – A New Foundation

Building A New Foundation

It’s been awhile since I’ve posted a video on Legend Bowl, so I thought I’d share some updates with you guys!

Let’s start with some back story to get you up to speed on all that’s happened since my last dev log.  Around May of last year, I took a detour and started working on another project I planned on trying to knock out in a few months.  Like any other software development project, things always take two to three times longer to finish and planning is almost always a difficult task to master.

Leading up to the break on Legend Bowl, my main developer was beginning to distance himself and eventually left the project without any notice or warning.  Fast forward 6 months and now I’m back at Legend Bowl 100% and I’m rebuilding the code base from scratch.  Yea that’s right, from scratch!

The reason is two fold… for starters the previous code base was too robust and things were beginning to get a bit unorganized and cumbersome.  Secondly, since my developer left I thought it was time for be to quickly transition into something more manageable.  Something I could build on my own to be 100% intune with all aspects of the project without depending on another coder.

I’ve been working on Legend Bowl again since the start of the new year.  I’m super excited to get this project moving and I’ve made quite a bit of progress leading up to this post.  My plan is build a brand new “state” system which allows me to isolate player behaviors and animations without needing to jump through 20 hoops to get there.  This will be the foundation of the new engine and will allow for quicker tuning for improved gameplay and behavior.

The plan is to get the on-field game working at some basic level and then move onto the polish.  I’ll be sharing the journey with new videos and I progress through this phase so stay tuned!

Indie Dev Life #15 – Initial Gameplay Showcase

Initial Gameplay Showcase

Have you been waiting to see some type of gameplay?  Well you’re in for a treat because we go through quit a bit in this video.

This video covers all of the new features in Legend Bowl and we’re excited to show the latest and greatest.  We will run through a new UI system, a Training Simulator, and Gameplay (if that’s what you want to call it).

User Interface / Experience (UI/UX)

Splash screen with new logo.

The game is coming along well, but there’s still a ton more work and it’s nowhere near close to anything for the public to see.  With that said, I’ve added some things to begin forming something that looks like an actual game.  This was done by adding UI/UX screens to the game, starting with a simple splash secreen using the new red & blue Legend Bowl logo recently made by our artist.

These screens are all placeholders for now, but are a massive help to test the game and navigate without having to change code and restart each time.  This will speed up the testing aspects of the game as we begin to move into the deeper mechanics like complex “Steering Behaviors” and “Artificial Intelligence”.

New UI changes to main menu.

The Main Menu consists of several options, but all are not functional at the moment.  We will breakdown each menu item briefly to cover what each does or will be intended to do.

Play Football – Similar to the “Play Now” menu in other sports titled video games where you go to the field and have some pigskin battles!  Currently, this menu simply loads two random teams onto the field and pins them together for some simple gameplay.

New Coin Toss with UI.

New Story – Future menu for the RPG component of Legend Bowl, where you go on a quest to build your player and construct a team in hopes of winning it all one day!

More menu mockups.

Load Story – Will load the story Save file to continue your adventure.

Training Camp – This is the simulator, currently utilized to “hone” in on specific gameplay aspects (throwing, catching, tackling, kicking, lineman interactions, etc.) in hopes of refining them to one day transport into the game.  This mode will eventually become a practice facility with special skills challenges to help boost your player/team abilities and collect new goodies in the process!

Throwing Simulator

New Throwing Simulator to test out your skills!

We are in the process of drastically improving the player movement (every actor in the game for that matter) in the game and Steering Behaviors need a reboot.  We have them in the game now, but there are issues and limitations with the current version which cause Referees to get stuck, Cameramen to miss their destinations and “float” by and Players to disappear off the screen!

Steering Behaviors Revisited

Steering Behaviors prototyping.

This prototype will aid in this goal and, like the Simulator, it really helps isolate the core functionality, while excluding any unrelated mechanics that may interfere with the code.  We hope to see some new behavior soon, but as with anything else, it will take time and need refinement along the way.

Options – Exactly what it means and what every game includes.  So no need to dive into this one just yet.

Quit To Desktop – Say bye bye to game when you click this puppy!

Well that’s it for now fans!  Be sure to checkout the video for a deeper look into these new updates and stay tuned for upcoming news on where Legend Bowl lands next!

Join our Discord channel today to get access to exclusive content daily!

 

 

 

Meet the Press

Press

The game of Football is not limited to just the onfield gameplay, but also the atmoshphere in which it is played.  Legend Bowl plans on filling stadiums with the little things some other games might choose to overlook.  Not us… we want as much ambience as framerates will allow! 🙂

Games broadcasted by the Press crew.

The Press team will be taking photos and recording games live for the world to watch!  Capturing the onfield gameplay is all part of the thrill of it.  We want the game to “feel” real both on the field and off.

Player Customizations & Unlockables

Customizations

Do you like customizations?  What about unloclable abilities or equipment?  These are all things coming into the game to make it as customizable as possbile.

Facemasks and Player body types.

The goal is to have fully customizable player characters.  You’ll be able to change faces to your liking.  Player likeness will be elevated in Legend Bowl to make each and every team look and feel different.

Concept art faces to illustrate customizations.

There will be a Player Card area where you can modify your equipment and see statistics for your players.  This screen will show what abilities boosts each piece of equipment will give your player for unlocked assets.

Unlock special equipment boosts!

You can unlock new equipment by completing special challenges and achievements in the game.  Plans are to have an extensive list of add-ons to your player so they can each have something new to bring to the gameplan and strategy.

Clear face shields in game!

Helmet types will be plentiful as well.  You’ll have the option to add face shields to your helmets to show off your killer instincts.  There will be a few colors to choose from and some will have ability boosts as well.

Throwing Physics

Sports games are always some of the most difficult titles to pull of in the video game world.  This is due to the physics aspects and calculating all the real-time variables on the field.

The throwing mechanics are something Legend Bowl has taken very seriously.  We would like the game to mimic the physics of a real football being thrown through the air and we feel we’ve accomplished just that!

Early throwing prototype done from a side-view perspective.
Early tests of throwing a ball at every 360 degree angle!
Testing the many ranges and angles a ball can travel through the air.
Throwing mechanics put into game to illustrate the ball movement.
Trigger happy, eh?

Football Field Origins

Pixel Football Field

Making the field was a process that took some time to complete.  Getting the player sprites to be the correct dimensions in a field was no easy task.

Football Field to Player aspect ratios.

The dimensions of a real-life football field were not simple to add either.  We wanted to make sure the game had as close to the real dimensions of a pro football field as possible.  This meant tracing every inch and constructing a field that was true to life!

Field dimensions chart.

Meet the Officiating Crew

Officials

Yes, I know, these guys have important roles to play in Legend Bowl.  No cheating allowed, even by the Refs!  No seriously, 7 types of referees have been added to the game to give it true authenticity.

FWEEEEEEEEEEEEEEEEEEE!!!!!!!!
Referee (R)  

Known as the “crew chief”… wears a white cap and is the final authority on rulings and instant replays.

Umpire (U)  

Stands behind line of scrimmage and watches for any holding or blocking penalties.

Line Judge (LJ)  

Positioned on opposite sideline from the down judge, looking down the line of scrimmage.  Watches for offsides and encroachment.

Field Judge (FJ)  

Stands 20 yards or so in the defensive backfields and watches any illegal use of hands and blocking fouls in the area.

Down Judge (DJ)  

Works from the sideline opposite of the press box, looking down the line of scrimmage.  Looks for any offsides or encroachment infractions.

Side Judge (SJ)  

Sits on the same side as (DJ) about 20 yards behind and watches the clock, keeps time, and counts defensive players on field.

Back Judge (BJ)  

Positioned deep in the defensive secondary about 25 yards, generally on the tight end’s side.  Focuses on tight end and actions surrounding him.