Author Archives: rahulmadanahalli

Bot Sees the Future in Ultimate Tic Tac Toe (In Progress)

work_in_progress

Ultimate Tic Tac Toe gives a second depth to the game of Tic Tac Toe. The rules of the game make it a strategic, intellectual, and addicting game.

Rules of the game: http://mathwithbaddrawings.com/2013/06/16/ultimate-tic-tac-toe/

I am currently working on an artificial intelligence for this game that can anticipate and optimize future outcomes in order to outwit its human opponent. I have created my own Node and Node Tree data structure, which I will use to record and analyze future moves. I am doing an implementation of the minimax algorithm for this artificial intelligence. It is truly challenging to create an effective and time efficient data structure for finding the best move to make.

After I have finished this project, I hope to put it on the Android market, so stay tuned for the final result!

Robots made by Artists

Hoffman's robot

Robots have been always made by computer scientists and mathematicians, but what would the Artificial Intelligence be like if it was made by an artist. This robot has a soul, and its risk-taking, adventurous, improvisational characteristics contrast the commonplace planning and analytical robot. Guy Hoffman, an animator and actor, worked on getting robots to collaborate with humans, especially through music. Hoffman’s robot can improvise with jazz musicians, and even head bob to rappers.

Guy Hoffman’s TED talk: http://www.youtube.com/watch?v=utV1sdjr4PY

Bot Learns from Experience in Ultimate Tic Tac Toe

Ultimate Tic Tac Toe gives a second depth to the game of Tic Tac Toe. The rules of the game make it a strategic, intellectual, and addicting game.

Rules of the game: http://mathwithbaddrawings.com/2013/06/16/ultimate-tic-tac-toe/

I created an artificial intelligence for this game using case based reasoning, where the computer would be able to learn from its previous game experiences. You can read more about the project description under the EPGY Projects tab of the EPGY Summer AI 2013 page. Here is a short summary of what I did.

I set up a localhost MySQL server in order to record each game in a table within a single database. After I access all the data from my previous games, I sort through the moves and only analyze the winner’s moves from each game. Then, I divide each game into three equal sections and classify each move into the section of the game that it was played in. I took these three individual clusters of moves and created a probability model for each cluster. The computer player would then apply one of these models depending on the computer player’s depth into the current game. I decided to use a probability model to create a dynamic computer player because dynamic gameplay is hard to exploit since it is unpredictable. Plus, this gives the human player the feeling that it is playing against a sophisticated, human-like bot.

My initial goal was to make the java game playable on this wordpress blog. Since I can’t add jar files to posts, I installed a separate WordPress.org blog on my localhost Apache server with the back-end on my localhost MySQL server. Next, I changed the functions.php page to allow me to load the jar files. Then, I was going to link this blog to my WordPress.org blog, but that would require port forwarding, which is a security hazard. Thus, I can only show you a video of the game. Check out the Youtube link below!

http://www.youtube.com/watch?v=HWzwAXzi0tk&feature=youtu.be

Check out my git repo as well:

https://github.com/rahulmadanahalli/UltimateTicTacToe.git

 

Artificially Intelligent bots can see the Future

AB_pruning.svgtumblr_m4f17gQPNl1r70663

Alpha Beta Pruning is a widely used concept for computer players in two player games, such as Tic Tac Toe or Chess. It gives computers the ability to make very intelligent moves by anticipating future gameplay.

First, the computer player creates a decision tree of future possible moves made by the computer and its opponent. Alpha beta pruning uses the minimax algorithm to expediently search through the decision tree for the most intelligent future course of moves. The minimax algorithm assumes that the opponent will try to minimize the computer’s chance of winning and the computer player will try to maximize it (a fair assumption). Therefore, using this algorithm, the computer anticipates the opponents moves and is able to choose the path to maximize its score. The pruning algorithm expedites the search process by weeding out branches of the decision tree that would not occur according to the minimax algorithm assumption.

This ability gives computer players a sense of foresight in games and allows them to be a worthy adversary for human players.

Helpful links to learn more:

https://en.wikipedia.org/wiki/Monte_Carlo_method#Artificial_intelligence_for_games

https://en.wikipedia.org/wiki/Minimax#Minimax_algorithm_with_alternate_moves

Tagged , , ,

Project “Ultimate Tic Tac Toe”

  1. Abstract

The popularity of the intellectual, addicting game, Ultimate Tic Tac Toe, is rising exponentially, yet the game lacks a sophisticated artificially intelligent computer player to challenge human players. At the Artificial Intelligence course in EPGY, I worked on a novel approach to the AI for Ultimate Tic Tac Toe. Instead of making computers act like humans, I was inspired to make computers THINK like humans by allowing them to learn from past experiences, which is the concept of case based reasoning. Human intelligence is not defined by what humans know; it is defined by “how” we know. My goal is to replicate true human intelligence through implementing case based reasoning on this game. By completing this project, I hope to expand the case based reasoning’s range of application and contribute new ways to implement case based reasoning.

2. Background on Case Based Reasoning

In order to create the most intelligent artificial system for a game, one must consider what makes the computer’s opponent, the human, a worthy adversary. Above all other human capabilities, the ability to learn from experiences makes humans the most intelligent life forms. My purpose is to replicate this behavior and thought process in a computer bot so that it will grow in intelligence after every game.

The primary process in case based reasoning is the 4 R’s: retrieve, reuse, revise, and retain. In a current situation, the computer player will first retrieve, or examine actions in similar past experiences. After accumulation of past experiences, the computer will mutate the past experience (reuse and revise) in order to make it fit in the current situation. If the action in the current situation was successful, then the action will be retained, and recorded as a successful past experiece. As this cycle iterates, a computer player will become more and more intelligent after every consecutive game it has played.

4rs

3. Application- What is Ultimate Tic Tac Toe?

Ultimate Tic Tac Toe is defined as a 3×3 Tic Tac Toe game in which each square has its own tic tac toe game.

tictac

The picture above best describes the gameboard for this game. A comprehensive guide to the rules of this game can be found in here (http://mathwithbaddrawings.com/2013/06/16/ultimate-tic-tac-toe/). The rules of the game make it very intellectual and thus, very addicting. Therefore, creating a bot with learning capabilities for such a complicated game is a novel proposition.

4. Previous Work in Case Based Reasoning

To create computer bots for the artificial intelligence Starcraft conferences, many teams implement case based reasoning so that their computer player can use tactics from its previous opponents and battles in order to succeed in its current situations. Also, corporations such as Verdande technology use case based reasoning in their products. Their data mining product, Edge Platform, uses previous problems and solutions to tackle current situations. Even though this product is used broadly across various fields, the computer can find similarities between situations of different clients and perform optimally.

Edge_Platform

5. Current AI in Ultimate Tic Tac Toe

Ultimate Tic Tac Toe applications on the web most commonly have random, unintelligent computer players. There is one on the khan academy website that uses a monte carlo search tree (MCST) to make moves. MCST evaluates every next move by simulating games that would occur after each move. Then the computer player chooses the next move that guarantees the most amount of future optimal results. This implementation allows the computer to think in advance and makes moves accordingly.

mcst

However intelligent this gameplay might seem, this does not prevent the computer player from making mistakes over and over again. If a computer player isn’t able to use case based reasoning to learn from experiences, a human player may exploit this discrepancy and be able to beat the computer player every time by  making the computer make the same mistake every time. The current AI for Ultimate Tic Tac Toe doesn’t significantly challenge human players and becomes very easy to beat after exploitation.

6. Proposed Solution

I set up a localhost MySQL server in order to record each game in a table within a single database. With the JDBC driver, I am able to connect my JAVA application to the MySQL server during a game. After I access all the data from my previous games, I sort through the moves and only analyze the winner’s moves from each game. After playing the game several times, I realized that the game strategy and technique changes at different points of the game. Furthermore, human players prioritize which square to play in depending on their depth into the game. Therefore, I divide each game into three equal sections and classify each move into the section of the game that it was played in. Then, I took these three individual clusters of moves and created a probability model for each cluster. The computer player would then apply one of these models depending on the computer player’s depth into the current game. I decided to use a probability model to create a dynamic computer player because dynamic gameplay is hard to exploit since it is unpredictable. Plus, this gives the human player the feeling that it is playing against a sophisticated, human-like bot.

mysql

Shows the localhost MySQL server I used to save past game experiences.

7. Conclusion

The bot for my game is just like the camel in this old proverb. I, the camel owner, had given the camel all the resources and wisdom to guide it to the water, but only the camel could decide if it wanted to drink water or not. I had given the AI bot a myriad of experience and the ability to cleverly analyze, yet would my bot use the resources to play better or fail? The artificially intelligent bot was extremely bad player after playing one or two games, but after it got more and more experience under its belt, it played with more sophistication and demonstrated a greater understanding for the game.  It even inherited tactics and strategies from previous players and implemented them in its future gameplay. The probability model made it impossible to exploit and an even more worthy adversary for the human player. Players for this game comment that it was much more challenging than the MCST computer player for this game.

exampleWin

The computer player (O) defeats one of my friends (X)

8. Future Work

I hope to implement alpha-beta pruning or MCST to the computer player so that I can create a Perfect Bot that will use both foresight and hindsight to become an extremely difficult player to beat. I am also looking forward to specify the classification of the previous games’ data, and implement markov chains in order to create smarter and more specific probability models. Above all, I hope to release a free version of this game on the Android market.

9. References

http://en.wikipedia.org/wiki/Case-based_reasoning

http://artint.info/html/ArtInt_190.html

http://www.youtube.com/watch?v=87FhSfvOiwU

http://www.verdandetechnology.com/home/products-and-services/edge-platform/

https://www.khanacademy.org/cs/in-tic-tac-toe-ception-perfect/1681243068

Tagged , , , , , ,

EPGY Book Proposition

Inside Case-Based Reasoning (Artificial Intelligence Series)

I would greatly benefit by having this book for my final project because of its comprehensive and in depth explanation and insights into the field of case based reasoning. It even provides Lisp programming exercises to improve my skills in case based programming applications. By helping me by this book, my instructor will be able to gain repute since my project will yield a lot of publicity and ROI (return on investment) if I have this book. I will even cover a portion  of the book’s cost, so it’s the best deal in town!

http://www.amazon.com/Inside-Case-Based-Reasoning-Artificial-Intelligence/dp/0898597676/ref=sr_1_10?s=books&ie=UTF8&qid=1374873138&sr=1-10&keywords=case+based+reasoning

Shout out to my instructor, Sherol Chen, for giving us an opportunity to buy books for our final project.

Recursion

“In order to understand recursion, one must first understand recursion.”

Recursion is, by far, one of my most favorite concepts in computer science. It can be used to solve many hard problems and some of its implementations are beautiful. This is a visual recursion program that I did with circles. At a depth of about 20, the circles turn into triangles and one can see a Sierpinski triangle.

Get even faster with ASP

 

Answer Set Programming is logic-based syntax such as Prolog, except it runs much faster. It does not have user input components or abilities to read or write to files. ASP’s and Prolog’s syntax is relatively the same even though they use relatively different technology.

In this project, I was given a program and had to terminate the fluent(heat).  Fluent is an event that has a fickle status that can happen, or terminate. You can check out my code under my Pastebin portfolio (link is in the Links page above) in the paste “Turn off the heat.” I used the following link to run the program  http://chapaai.adamsmith.as:8118/

After so much time with imperative and OO programming, ASP gives us a taste of no control flow and declarative programming. It expedites the process of creating projects too because I don’t have to create objects, classes, etc. This language makes it very easy to initiate environment and states if one is able to simplify any project to a collection of boolean arguments.

As you can see below, the heat is showing negative values after time T =5 when I initiated the event, air conditioning.

Tagged , ,

Dipping into Prolog

How could I have continued to SQL without looking at the prolog? (hahaha)

Prolog is a logic-inspired programming language that is used for game artificial intelligence, such as story generation and level generation. In my project with Prolog, I used abduction reasoning to create the following situation: The dining hall has chocolate ice cream, but not vanilla. I also made it understand family hierarchy. You can see my work in Prolog in my Pastebin link on the Links page above!

The statements after the “:-” has to be initiated in order for the statements before the “:-” to be initiated. After I initiated the dining hall as a place, it inherited characteristics from the statements preceding it. I ran prolog using this application here: http://waitaki.otago.ac.nz/~michael/wp/

I’m hoping to learn more prolog with this neat tutorial: https://www.csupomona.edu/~jrfisher/www/prolog_tutorial/contents.html

Image

Tagged ,

Image Recognition – KM Clustering

On famous apps such as Hot or Not, the program judges the hotness of a person based on the aesthetic value from a picture of that person. Programs like this use KM clustering at the base level to categorize similar pixels.

I implemented KM clustering to give fancy, instagram-like effects to any picture. This program allows the user to enter in several “seed pixels,” and every pixel in the image will be grouped with the seed pixel that has the closest color. I used an algorithm similar to the kNN classification project to group the pixels into clusters. Then I took the average color value of all the pixels in each cluster and applied it to all the pixels in that cluster. Repeating the above steps around 20 times will drastically change the coloring of the picture, yet the picture features will still be preserved.

original picture of obama

original picture of obama

after 3 iterations

after 3 iterations

red, white, and blue obama after 20 iterations

red, white, and blue obama after 20 iterations

From this project, I really enjoyed how I could reuse skills and techniques from past projects in order to save time!

Tagged , ,