Artificial Intelligence Based Automatic Generation of Entertaining Gaming Engines Dr. Zahid Halim Faculty of Computer Science and Engineering Ghulam Ishaq Khan Institute of Engineering Sciences and Technology, Topi zahid.halim@giki.edu.pk 19th June 2012 Layout Artificial Intelligence AI What is not AI and application of AI ~ AI Case Study Results Q/A 2 Nuts and bolts of a predator/prey gaming engine Results of the experiment Questions Artificial Intelligence based Automatic generation of Entertaining Gaming Engines Artificial Intelligence (AI) • • Intelligence is the computational part of the ability to achieve goals in the world One of the most dumbest thing in world is computer • Recall the two numbers addition program using int data type • Artificial intelligence allows computers to • Think like humans • Learn from experience • Recognize patterns in large amounts of complex data • Make complex decisions based on knowledge and reasoning skills 3 Artificial Intelligence based Automatic generation of Entertaining Gaming Engines Everything fast is not AI AI is not NOT AI • • • A meter reading algorithm at petrol pumps Encyclopedia SQL query AI • • • 4 TOPIO, humanoid robot can play ping-pong with human Speech and Voice Recognition Face recognition Artificial Intelligence based Automatic generation of Entertaining Gaming Engines AI tools • • • • Artificial Neural Networks Swarm Intelligence Evolutionary Computation Pruning Algorithms : : : (and the list goes on) 5 Artificial Intelligence based Automatic generation of Entertaining Gaming Engines Automated Game Generation A Case Study Predator/prey Games Search Space • • 14 X 14 grid excluding the boundary • walls. • No movement Couple of walls at fixed positions • Clockwise • Counter clockwise • Random • Random direction and of size 7 cells • There is one player controlled by the human player. • Movement logic There are N (0-20)other pieces of M • Collision logic (1,2 and 3) types • • • no effect • random relocation to a new Maximum duration 100 game steps Finish game • Agent dies • Maximum score is achieved • Maximum game steps location on the grid • • death. Scoring logic • +1, -1, 0 utilized 7 Artificial Intelligence based Automatic generation of Entertaining Gaming Engines Chromosome Encoding for Genetic Algorithm Number of predators Movement logic Collision logic 8 Red 0-20 Blue-Green 0-2 Green 0-20 Blue-Blue 0-2 Blue 0-20 Blue-Agent 0-2 Red 0-4 Agent-Red 0-2 Green 0-4 Agent-Green 0-2 Blue 0-4 Agent-Blue 0-2 Red- Red 0-2 Red- Red -1,0,+1 Red- Green 0-2 Green-Green -1,0,+1 Red-Blue 0-2 Blue-Blue -1,0,+1 Red- Agent 0-2 Agent-Red -1,0,+1 Green-Red 0-2 Agent Green -1,0,+1 Green-Green 0-2 Agent-Blue -1,0,+1 Green-Blue 0-2 Green-Red -1,0,+1 Green-Agent 0-2 Blue-Red -1,0,+1 Blue-Red 0-2 Blue-Green -1,0,+1 Collision logic Score logic Artificial Intelligence based Automatic generation of Entertaining Gaming Engines Entertainment Metrics • • • • 9 Duration of the Game Appropriate Level of Challenge Diversity Usability D = ( nK 0 Lk )/n ( C=e |S m S a | ) Sm n m i 1 k 0 Div = ( ( (d k )))/n n m i 1 k 0 U = ( (( (C k )) / | Cu |))/n Artificial Intelligence based Automatic generation of Entertaining Gaming Engines Rule Based Controller • • The controller looks up, down, left and right. It notes the nearest piece (if any) in each of the four directions, and then it simply moves one step towards the nearest score increasing piece If there are no score increasing piece present it determines its step according to the following priority list • Move in the direction which is completely empty • If more than one directions are empty move towards the farthest wall • Move in the direction which contains a score neutral piece • Move in the direction which contains a score decreasing piece • Move in the direction which contains a death causing piece 10 Artificial Intelligence based Automatic generation of Entertaining Gaming Engines Neural Network Based Controller • • • • • • Multi-layer fully feed forward 6 neurons in the input layer 5 neurons in the hidden layer 4 output layer neurons Sigmoid activation function ∆xr Edges weights -5 to +5. ∆yr ∆xg ∆yg ∆xb ∆yb 11 C o n n e c ti o n E d g e s C o n n e c ti o n E d g e s C o n n e c ti o n E d g e s Nu Nd Nl Nr Artificial Intelligence based Automatic generation of Entertaining Gaming Engines Experimentation Setup • 10 chromosomes are randomly initialized by the GA • One offspring is created for each chromosome • • • • Duplicating it Mutating any one of its gene Results in 20 chromosomes from which 10 best chosen 100 generations 12 Artificial Intelligence based Automatic generation of Entertaining Gaming Engines Duration of game Predators Movement logic G B R G B 17 13 3 0 3 Collision logic B -G B-B B-A A-R A-G A-B 2 2 2 0 0 2 R 3 Predators Movement logic G B R G B 18 10 0 1 3 Collision logic B -G B-B B-A A-R A-G A-B 1 1 1 1 0 2 R 0 R-R 2 R-G 1 R-B 1 R-R -1 G-G -1 B-B 0 R-R 2 R-G 2 R-B 1 R-R 0 G-G 1 B-B 0 Collision logic R-A G-R G-G 0 0 1 Scoring logic A-R A-G A-B -1 0 0 Collision logic R-A G-R G-G 1 2 0 Scoring logic A-R A-G A-B 1 -1 -1 G-B 0 G-A 2 B-R 1 G-R -1 B-R -1 B-G 0 G-B 0 G-A 1 B-R 1 G-R 1 B-R -1 B-G -1 (a) (b) Appropriate level of challenge Predators Movement logic G B R G B 0 11 0 0 3 Collision logic B -G B-B B-A A-R A-G A-B 2 2 2 2 0 2 R 10 Predators Movement logic G B R G B 7 8 2 4 3 Collision logic B -G B-B B-A A-R A-G A-B 0 0 0 2 0 2 R 7 Diversity Predators Movement logic G B R G B 10 0 2 4 2 Collision logic B -G B-B B-A A-R A-G A-B 1 0 2 1 0 2 R 0 Predators Movement logic G B R G B 17 0 4 4 4 Collision logic B -G B-B B-A A-R A-G A-B 1 1 2 1 0 2 R 0 13 R-R 0 R-G 1 R-B 2 R-R -1 G-G 0 B-B -1 R-R 1 R-G 2 R-B 0 R-R -1 G-G -1 B-B 0 Collision logic R-A G-R G-G 1 2 0 Scoring logic A-R A-G A-B 1 0 -1 Collision logic R-A G-R G-G 0 0 1 Scoring logic A-R A-G A-B 0 -1 -1 G-B 2 G-A 0 B-R 1 G-R 0 B-R -1 B-G -1 G-B 2 G-A 2 B-R 1 G-R -1 B-R 1 B-G 0 R-R 1 R-G 2 R-B 1 R-R 1 G-G 1 B-B -1 R-R 2 R-G 0 R-B 2 R-R -1 G-G 0 B-B 0 Collision logic R-A G-R G-G 1 0 0 Scoring logic A-R A-G A-B 0 1 -1 Collision logic R-A G-R G-G 2 0 0 Scoring logic A-R A-G A-B 0 1 1 G-B 2 G-A 0 B-R 2 G-R -1 B-R 1 B-G 0 G-B 2 G-A 1 B-R 2 G-R 1 B-R 1 B-G 0 (a) (b) (a) (b) Artificial Intelligence based Automatic generation of Entertaining Gaming Engines Usability Predators Movement logic G B R G B 18 19 1 2 2 Collision logic B -G B-B B-A A-R A-G A-B 2 2 0 2 0 2 R 20 Predators Movement logic G B R G B 20 20 4 4 2 Collision logic B -G B-B B-A A-R A-G A-B 2 0 2 2 0 2 R 19 R-R 2 R-G 0 R-B 0 R-R 1 G-G -1 B-B 0 R-R 2 R-G 0 R-B 2 R-R -1 G-G -1 B-B 1 Collision logic R-A G-R G-G 2 2 1 Scoring logic A-R A-G A-B 1 0 0 Collision logic R-A G-R G-G 2 2 2 Scoring logic A-R A-G A-B -1 1 1 G-B 2 G-A 0 B-R 2 G-R -1 B-R 0 B-G 0 G-B 0 G-A 2 B-R 2 G-R 0 B-R -1 B-G -1 (a) (b) Combined Fitness Predators Movement logic G B R G B 8 3 1 1 0 Collision logic B -G B-B B-A A-R A-G A-B 2 2 0 0 0 0 R 15 Predators Movement logic G B R G B 20 3 2 4 2 Collision logic B -G B-B B-A A-R A-G A-B 1 1 2 0 0 2 R 11 14 R-R 1 R-G 2 R-B 0 R-R 1 G-G 1 B-B -1 R-R 2 R-G 2 R-B 0 R-R 0 G-G 1 B-B 1 Collision logic R-A G-R G-G 0 1 0 Scoring logic A-R A-G A-B -1 -1 1 Collision logic R-A G-R G-G 2 2 2 Scoring logic A-R A-G A-B -1 1 0 G-B 1 G-A 2 B-R 0 G-R -1 B-R -1 B-G -1 G-B 0 G-A 1 B-R 1 G-R -1 B-R 0 B-G 1 (a) (b) Artificial Intelligence based Automatic generation of Entertaining Gaming Engines Controller Learning Ability Random Combined-ANN Combined-RB Usability-ANN Challenge-ANN Duration-ANN Diversity-ANN Usability-RB Challenge-RB Duration-RB Diversity-RB 0 200 400 600 800 1000 1200 Diversity- Duration- Challeng Usability- Diversity- Duration- Challeng Usability- Combine Combine Random RB RB e-RB RB ANN ANN e-ANN ANN d-RB d-ANN No. Of Iterations 3 5 6 1000 71 1000 1000 64 320 310 63 15 Artificial Intelligence based Automatic generation of Human User Survey ANN BasedDuratio Controller •User Survey • • 10 subjects Conducted in two different sets on different days • • • • 12 10 8 6 4 2 0 16 n 4% Rando m 0% Rule based controller ANN based controller Each individual was given 6 games Play 2 times Rule Based Controller ANN Based Controller Combin ed Fitness 40% Challen ge 32% Usability 24% Random 0% Diversity 0% Human User Survey Rule Based Controller Duration 12% Combine d Fitness 47% Challeng e 23% Usability 18% Diversity 0% Artificial Intelligence based Automatic generation of Thank you for your patience Questions This presentation is uploaded at http://ming.org.pk/zahid.htm Bibliography • Halim, Zahid, A. Rauf Baig, and Hasan Mujtaba. "Measuring entertainment and automatic generation of entertaining games." International Journal of Information Technology, Communications and Convergence 1.1 (2010): 92-107. • Halim, Zahid, A. Rauf Baig, and Mujtaba Hasan. "Evolutionary Search For Entertainment In Computer Games." Intelligent Automation & Soft Computing 18.1 (2012): 33-47. • Halim, Zahid, and A. Raif Baig. "Evolutionary Algorithms towards Generating Entertaining Games." Next Generation Data Technologies for Collective Computational Intelligence. Springer Berlin Heidelberg, 2011. 383-413. • J.Schmidhuber, ”Developmental robotics, optimal artificial curiosity, creativity, music, and the fine arts”, Connection Science, vol. 18, pp.173–187, 2006 • N. Esposito, “A Short and Simple Definition of What a Videogame Is”, in proceedings of Digital Games Research Association (DiGRA), Vancouver, Canada, 16-20 June, 2005 • J.Smed and H.Hakonen, "Towards a Definition of a Computer Game", Technical Report, Computer Games Research Group, Department of Information Technology, University of Turku, Finland, 2005 • http://www.glasbergen.com/computer-cartoons/ • http://www-formal.stanford.edu/jmc/whatisai/node1.html • G. N. Yannakakis , J. Hallam, ”Towards Optimizing Entertainment In Computer Games”, Applied Artificial Intelligence”, v.21 n.10, p.933-971, November 2007 • http://www.easy-marketing-strategies.com/writing-a-case-study.html • http://www.123rf.com/photo_9926111_confused-cartoon-guy.html 18 Artificial Intelligence based Automatic generation of Entertaining Gaming Engines