Artificial Intelligence Cameron Jett, William Kentris, Arthur Mo, Juan Roman AI Outline

● Handicap for AI ● Machine Learning ● Monte Carlo Methods ● Group Intelligence Incorporating stupidity into game AI overview

● Why make our intelligence less intelligent? ● Examples of unbeatable AI in games. ● How do we make our AI less intelligent? ● Problems in weakening AI. ● Conclusion. Why do we need to make our game AI less intelligent?

● Perfect AI can be impossible to defeat. ● Make the game balanced for many different kinds of people. ● Make the game fun. ● Games can be frustrating when they're too difficult. ● We want the player to win a game without feeling like the victory was handed to them. Unbeatable AI: Chess

● A chess game that never makes mistakes. Unbeatable AI: Pool

● A game of pool where the AI never misses a shot. Unbeatable AI: First-Person Shooter

● Enemies in a first-person shooter with perfect aim from any distance. How do we make our AI less intelligent?

● Limit the number of computations an AI is allowed to perform. ○ If a chess program performs a billion calculations before deciding on a move make it choose a move in half that many.

● Problems ○ This approach decreases the realism of the AI player, making incredibly stupid mistakes that no human player would make. How do we make our AI less intelligent?

● Changing an AI's attributes. ○ Lowering accuracy, movement speed, cone of vision, or amount of damage it can deal.

● Problems ○ This approach is better but not necessarily the best way to limit the games intelligence. ○ This can lead to random occurrences that have unintentional consequences, if the computer gets lucky it can seem like it's unfair or cheating. How do we make our AI less intelligent?

● Have the AI make intentional mistakes ○ The AI must make mistakes that look natural, but result in it losing the game. ○ Deliberately make mistakes that the player can take advantage of, and then continue trying to win.

● Problems ○ This approach is more complicated than the last two attempts, but leads to a more realistic gameplay. Conclusion

● A perfect opponent isn't fun, however an easy to defeat opponent is boring. ● We need a game AI that allows the player to win without feeling like the victory was given to them. ● We need an AI that makes the "right" kind of mistakes, those that an actual player might make. ● It's more difficult to write a "bad" game AI than it is to write a good one. Machine Learning Overview

● Define "Machine Learning" ● Why should machines learn? ● How do machines learn? ● Methods ● What does this mean for game development? What is Machine Learning?

● Machine Learning refers usually to AI ● An agent that improves performance with experience ● Ability to discover relationships between input and output ● Learning configuration of mazes Why should machines learn?

● Allow machine to operate with less human interaction ● Weather Prediction ● Language Recognition ● Spam Filtering How can machines learn?

● A machine learns whenever it changes its structure, program, or data ○ Changing input based on previous results ○ Classify input data ○ Updates to a database ○ Writing new code to run Supervised Learning Supervised Learning Reinforcement Learning

http://www.ise.pw.edu.pl/~cichosz/rl-java/ http://brain.cc.kogakuin.ac. jp/~kanamaru/NN/CPRL/ In Games

● Changing behavior of game based on player interaction ● Changing difficulty based on player progress ○ Assist less experienced players ○ Challenge more hardcore players Monte Carlo Overview

● What are Monte Carlo Methods? ● Monte Carlo approach to a game ● Advantages ● Disadvantages ● Improvements Monte Carlo Methods

● Repeated random sampling ● Coined by John Neumann, Stanislaw Ulam, and Nicholas Metropolis ● Used in physical and mathematical system simulations. ● http://en.wikipedia. org/wiki/File:Pi_30K.gif Monte Carlo approach to a game

● 4 in a Row(Connect 4) example ● Each turn run N random games. ● Track only initial move. ● Play rest of the game randomly. ● Track how often each move produces a victory. ● Go with the best move. ● http://beej.us/blog/data/monte-carlo- method-game-ai/ Advantages

● Easy to program. ● No high quality of domain knowledge needed. ● No cold starts. ● Space complexity is constant. Disadvantages

● Equal probability among choices. ● Selection is strictly Exploitative. Improvements

● MCTS(Monte Carlo Tree Search) ● UCT(Upper Confidence bounds applied to Trees) Bio-Inspired Algorithms

● Nature has become inspiration for new approaches ● Bio-Inspired Algorithms mimic the efficiency of biological systems ● Bio-Inspired Algorithms generally consist of: ○ Evolutionary Algorithms ○ Intelligence ○ Bacterial Foraging Algorithms

•Collective behavior of decentralized, self- organized systems. •Comprised of simple agents, “”, interacting with one another in an environment Why Swarm Intelligence?

•Provides us with method to have boids collaborate as a team •Improve quality of playing with/against AI Modeling Behaviors

•Recent algorithms for Group AI are typically modeled off of behaviors seen in nature. •Offer intuitive solutions to difficult problems. •Some popular ones include: Ant Colony Optimization, Firefly Algorithm, Krill Algorithm, and others. Modeling Behaviors

•Obviously, different algorithms are used to accomplish different goals. •For example, in an RTS, must balance utility of sending units to scout, forage for resources, and stay close enough to the group to stand decent chance of survival. Additionally, must organize offensive units to collaborate attacks on enemies. Ant Colony Optimization

•Mimics the pheromone trail used by ants; used to determine the most used path. •Boids model behavior of ants to follow the most potent trail left by fellow boids. Firefly Algorithm

•Mimics flashing behavior of fireflies; used to subdivide into small groups. •Uses features of individual boids to attract boids of a similar nature; results in ability to cluster into subgroups. Krill Herd Algorithm

•Mimics the krill’s dependency on herd density while attempting to forage for food. •Boids attempt to maximize friendly boid density (increase odds of survival), while collecting resources (or some other form of utility) Krill in Action Swarm Intelligence - Summary

● Swarm Intelligence ○ Nature inspired algorithms for group behaviors ○ Group Behaviors of boids > Individual Behaviors ○ Different Algorithms for Different Folks ■ Grouping/Clustering ■ Search Optimization (Foraging) ■ Self-preservation

● Next Time! ○ In-depth look at the 3 Algorithms ○ Applications of the 3 Algorithms (games and IRL) Questions?

"What is 'No', Alex?"