Introduction to Artificial Intelligence CS 151 Programming Assignment 2 Mancala!! Due (in dropbox) Tuesday, September 23, 9:34am

Similar documents
For slightly more detailed instructions on how to play, visit:

CS151 - Assignment 2 Mancala Due: Tuesday March 5 at the beginning of class

1 Introduction. 1.1 Game play. CSC 261 Lab 4: Adversarial Search Fall Assigned: Tuesday 24 September 2013

ARTIFICIAL INTELLIGENCE (CS 370D)

Module 3. Problem Solving using Search- (Two agent) Version 2 CSE IIT, Kharagpur

mywbut.com Two agent games : alpha beta pruning

Homework Assignment #2

1 Modified Othello. Assignment 2. Total marks: 100. Out: February 10 Due: March 5 at 14:30

Computer Science and Software Engineering University of Wisconsin - Platteville. 4. Game Play. CS 3030 Lecture Notes Yan Shi UW-Platteville

2 person perfect information

Artificial Intelligence Lecture 3

B551 Homework 2. Assigned: Sept. 15, 2011 Due: Sept. 29, 2011

Programming an Othello AI Michael An (man4), Evan Liang (liange)

Game Playing for a Variant of Mancala Board Game (Pallanguzhi)

CS 229 Final Project: Using Reinforcement Learning to Play Othello

CS 440 / ECE 448 Introduction to Artificial Intelligence Spring 2010 Lecture #5

AI Approaches to Ultimate Tic-Tac-Toe

CSC 110 Lab 4 Algorithms using Functions. Names:

Assignment 2 (Part 1 of 2), University of Toronto, CSC384 - Intro to AI, Winter

Games (adversarial search problems)

CS 2710 Foundations of AI. Lecture 9. Adversarial search. CS 2710 Foundations of AI. Game search

Adversarial Search (Game Playing)

CS 1571 Introduction to AI Lecture 12. Adversarial search. CS 1571 Intro to AI. Announcements

More Adversarial Search

CMPUT 396 Tic-Tac-Toe Game

Assignment 2, University of Toronto, CSC384 - Intro to AI, Winter

game tree complete all possible moves

Pay attention to how flipping of pieces is determined with each move.

Algorithms for Data Structures: Search for Games. Phillip Smith 27/11/13

Documentation and Discussion

Adversary Search. Ref: Chapter 5

CSE 3401 Assignment 4 Winter Date out: March 26. Date due: April 6, at 11:55 pm

Game-playing AIs: Games and Adversarial Search I AIMA

Artificial Intelligence. Minimax and alpha-beta pruning

CSE 332: Data Structures and Parallelism Games, Minimax, and Alpha-Beta Pruning. Playing Games. X s Turn. O s Turn. X s Turn.

2359 (i.e. 11:59:00 pm) on 4/16/18 via Blackboard

CS 771 Artificial Intelligence. Adversarial Search

CPSC 217 Assignment 3 Due Date: Friday March 30, 2018 at 11:59pm

CSCI1410 Fall 2018 Assignment 2: Adversarial Search

The game of Reversi was invented around 1880 by two. Englishmen, Lewis Waterman and John W. Mollett. It later became

Adversarial Search Aka Games

Unit 12: Artificial Intelligence CS 101, Fall 2018

Adversarial Search and Game- Playing C H A P T E R 6 C M P T : S P R I N G H A S S A N K H O S R A V I

03/05/14 20:47:19 readme

Real-Time Connect 4 Game Using Artificial Intelligence

Artificial Intelligence Search III

Lecture 33: How can computation Win games against you? Chess: Mechanical Turk

Playing Games. Henry Z. Lo. June 23, We consider writing AI to play games with the following properties:

Game Playing AI Class 8 Ch , 5.4.1, 5.5

ADVERSARIAL SEARCH. Today. Reading. Goals. AIMA Chapter , 5.7,5.8

CMSC 671 Project Report- Google AI Challenge: Planet Wars

Five-In-Row with Local Evaluation and Beam Search

ADVERSARIAL SEARCH. Today. Reading. Goals. AIMA Chapter Read , Skim 5.7

Game-playing AIs: Games and Adversarial Search FINAL SET (w/ pruning study examples) AIMA

CS 540-2: Introduction to Artificial Intelligence Homework Assignment #2. Assigned: Monday, February 6 Due: Saturday, February 18

CPS331 Lecture: Search in Games last revised 2/16/10

COMP9414: Artificial Intelligence Adversarial Search

Artificial Intelligence 1: game playing

Learning to Play like an Othello Master CS 229 Project Report. Shir Aharon, Amanda Chang, Kent Koyanagi

Minimax Trees: Utility Evaluation, Tree Evaluation, Pruning

Foundations of AI. 5. Board Games. Search Strategies for Games, Games with Chance, State of the Art. Wolfram Burgard and Luc De Raedt SA-1

Game Tree Search. CSC384: Introduction to Artificial Intelligence. Generalizing Search Problem. General Games. What makes something a game?

Adversarial Search 1

University of Amsterdam. Encyclopedia of AI project. Tic-Tac-Toe. Authors: Andreas van Cranenburgh Ricus Smid. Supervisor: Maarten van Someren

Artificial Intelligence. Topic 5. Game playing

Game-Playing & Adversarial Search

COMP219: COMP219: Artificial Intelligence Artificial Intelligence Dr. Annabel Latham Lecture 12: Game Playing Overview Games and Search

Computer Game Programming Board Games

CSC 396 : Introduction to Artificial Intelligence

Set 4: Game-Playing. ICS 271 Fall 2017 Kalev Kask

Adversarial Search: Game Playing. Reading: Chapter

Announcements. Homework 1 solutions posted. Test in 2 weeks (27 th ) -Covers up to and including HW2 (informed search)

Board Game AIs. With a Focus on Othello. Julian Panetta March 3, 2010

CS510 \ Lecture Ariel Stolerman

COMP3211 Project. Artificial Intelligence for Tron game. Group 7. Chiu Ka Wa ( ) Chun Wai Wong ( ) Ku Chun Kit ( )

Using Artificial intelligent to solve the game of 2048

CS885 Reinforcement Learning Lecture 13c: June 13, Adversarial Search [RusNor] Sec

Programming Project 1: Pacman (Due )

CS221 Project Final Report Gomoku Game Agent

Foundations of AI. 6. Adversarial Search. Search Strategies for Games, Games with Chance, State of the Art. Wolfram Burgard & Bernhard Nebel

Solving Problems by Searching: Adversarial Search

Adversarial Search. Rob Platt Northeastern University. Some images and slides are used from: AIMA CS188 UC Berkeley

CS 188: Artificial Intelligence Spring Announcements

CS Project 1 Fall 2017

Today. Types of Game. Games and Search 1/18/2010. COMP210: Artificial Intelligence. Lecture 10. Game playing

Artificial Intelligence Adversarial Search

CSE 573: Artificial Intelligence Autumn 2010

CS 5522: Artificial Intelligence II

More on games (Ch )

V. Adamchik Data Structures. Game Trees. Lecture 1. Apr. 05, Plan: 1. Introduction. 2. Game of NIM. 3. Minimax

Game Playing. Why do AI researchers study game playing? 1. It s a good reasoning problem, formal and nontrivial.

Deep Green. System for real-time tracking and playing the board game Reversi. Final Project Submitted by: Nadav Erell

CPS 570: Artificial Intelligence Two-player, zero-sum, perfect-information Games

CMSC 201 Fall 2018 Project 3 Sudoku

2048: An Autonomous Solver

Announcements. Homework 1. Project 1. Due tonight at 11:59pm. Due Friday 2/8 at 4:00pm. Electronic HW1 Written HW1

Adversarial Search and Game Playing. Russell and Norvig: Chapter 5

COMP219: Artificial Intelligence. Lecture 13: Game Playing

Artificial Intelligence

CITS3001. Algorithms, Agents and Artificial Intelligence. Semester 2, 2016 Tim French

Transcription:

Introduction to Artificial Intelligence CS 151 Programming Assignment 2 Mancala!! Due (in dropbox) Tuesday, September 23, 9:34am The purpose of this assignment is to program some of the search algorithms and game playing strategies that we have learned in class. In particular, you will implement two aspects of an artificial intelligence game that plays Mancala (and other two-player games): search with alpha-beta pruning, and a game board evaluator. Your goals are to implement alpha-beta pruning correctly, and to create the best AI player you can. We will hold a tournament between the submitted players, and the winner of the tournament will receive a prize of some sort. (However, your placement in the tournament will have no effect on your grade). Part 1: Introduction to Mancala Mancala is a two-player game from Africa in which players moves stones around a board (shown above), trying to capture as many as possible. In the board above, player 1 owns the bottom row of stones and player 2 owns the top row. There are also two special pits on the board, called Mancalas, in which each player accumulates his or her captured stones (player 1's Mancala is on the right and player 2's Mancala is on the left). On a player's turn, he or she chooses one of the pits on his or her side of the board (not the Mancala) and removes all of the stones from that pit. The player then places one stone in each pit, moving counterclockwise around the board, starting with the pit immediately next to the chosen pit, including his or her Mancala but NOT his or her opponents Mancala, until he or she has run out of stones. If the player's last stone ends in his or her own Mancala, the player gets another turn. If the player's last stone ends in an empty pit on his or her own side, the player captures all of the stones in the pit directly across the board from where the last stone was placed (the opponents stones are removed from the pit and placed in the player's Mancala) as well as the last stone placed (the one placed in the empty pit). The game ends when one player cannot move on his or her turn, at which time the other player captures all of the stones remaining on his or her side of the board.

For slightly more detailed instructions on how to play, visit: http://www.pressmantoy.com/instructions/instruct_mancala.html. Part 2: Provided Code Download the provided code for the assignment, posted on the course web site on the Assignments page. I have provided code to support the basic game play, as well as a simple AI player (it's REALLY simple). It contains the following files: MancalaBoard.py: A file that contains a class that represents the Mancala gameboard. This class manages the gameboard, knows how to add moves, can return legal moves, can determine when a player has won, etc. Player.py: A player class that can be instantiated with several types: o HUMAN: a human player o RANDOM: a player that makes random legal moves o MINIMAX: a player that uses the minimax algorithm and the board score function to choose its next move, limited by a specified ply depth o ABPRUNE: a player that uses alpha-beta pruned search and the board score function to choose its next move, limited by a specified ply depth. This player is not yet supported (you will implement it). o CUSTOM: the best player you can create. This player is not yet supported (you will implement it). MancalaGUI.py: A simple GUI for playing the Mancala game. To invoke the game you call the startgame(p1, p2) function, passing it two player objects. TicTacToe.py: A file that contains a class representing a Tic Tac Toe gameboard, similar to what you implemented in Programming Assignment 1 You should download these files and make sure you can run them. To run a GUI game between two humans, load the file MancalaGUI.py (at a python interpreter execfile( MancalaGUI.py ) ). The GUI will not show up until the start the game using the commands below. Then create two players with type HUMAN (the ply is ignored for human players, and can be left as its default value): >>> player1 = Player(1, Player.HUMAN) >>> player2 = Player(2, Player.HUMAN) >>> startgame(player1, player2) You should see a window appear (it may appear in the background). You can now play Mancala with a friend. But what if you don't have a friend, you ask? Well, never fear! The computer will play against you (and I guarantee you will win). To play against the computer you simply need to create a computer player to play against, e.g: >>> startgame(player(1, Player.HUMAN), Player(2, Player.RANDOM)) # Ply is also ignored for random players or

>>> startgame(player(1, Player.HUMAN), Player(2, Player.MINIMAX, 5)) You can also play Tic Tac Toe using the same player object (but no GUI provided with Tic Tac Toe). Load the Tic Tac Toe game, create a new TTTBoard, and then use the "hostgame" function to play the game. Once you understand how to run the code, make sure you read though the provided code and understand what it does. Notice that the minimax algorithm we discussed in class has already been implemented. Part 3: A Better Board Score Function [45 points] The board score function in the basic player is too simple to be useful in Mancala--the agent will never be able to look ahead to see the end of the game until it's way too late to do anything about it. Your first task is to write an improved board score in the MancalaPlayer class, a subclass of Player. You may wish to consider the number of pieces your player currently has in its Mancala, the number of blank spaces on its side of the board, the total number of pieces on its side of the board, specific board configurations that often lead to large gains, or anything else you can think of. You should experiment with a number of different heuristics, and you should systematically test these heuristics to determine which work best. Note that you can test these heuristics with the MINIMAX player, or you can wait until you've completed part 4 below (alpha-beta pruning). In addition to your code, you will submit a short (1-2 paragraphs) writeup about how you chose your final score function. What did you try along the way? What worked well and how did you determine what works well? Part 4: Alpha-Beta Pruning search [45 points] The next part of the assignment is to implement the alpha-beta prune search algorithm described in your textbook and in class. Look in the code to see where to implement this function. You may refer to the pseudocode in the book, but make sure you understand what you are writing. In your alpha-beta pruning algorithm, you do NOT have to take into account that players get extra turns when they land in their own Mancalas with their last stones. You can assume that a player simply gets one move per turn and ignore the fact that this is not always true. Notice that my provided version of minimax also makes this simplifying assumption. This makes the scoring function slightly inaccurate. You have the option of fixing this inaccuracy in one of the extra credit options below. You probably wish to test your alpha-beta pruning algorithm on something simpler than Mancala, which is why I have provided the Tic Tac Toe class. Using alpha-beta pruning, it's possible for an agent to play a perfect game of Tic Tac Toe (by setting ply=9) in a reasonable amount of time. The first move will take the agent awhile (20 seconds or so),

but after that the agent will choose its moves quickly. Contrast this to minimax, where a ply greater than 5 takes an unreasonable amount of time. Test your algorithm carefully by working through the utility values for various board configurations and making sure your algorithm is not only choosing the correct move, but pruning the tree appropriately. You will need to submit at least one example that illustrates that your algorithm correctly prunes the search tree. For example, consider the board: X X O Your search will first try an O in the top right corner and should find that that move leads ultimately to a tie. Now consider this point in the search tree: X X _ O O where O has tried a move in the left, center spot. On the next level (when X plays in the top right), the algorithm immediately sees that X will win, resulting in a score of 0 for O. Since X is the min player, X will choose this move unless there is a move with an even LOWER value (which there is not). Thus, the best O can do is a score of 0 if it moves in the middle left. It does not need to try the other positions for X because it knows that it is not going to choose to play here (because blocking X in the top row leads to a score of 50, which is better). Thus the algorithm will prune the rest of the search tree at this point after it has tried the top right corner for X. To write this up, I would first illustrate that my program behaves correctly in this case by adding print statements to my code, which might then produce the following output: alpha is 50.0, score is 0.0. Aborted on move 2 in minvalue on XX2 OO5 678 Then I would explain what is going on as above. You should choose a different example when testing your code. Come see me if you have questions about this part. Your explanation of what is going on is worth a significant part of your grade, so be sure that you understand the above explanation and that you can produce one of your own. Part 5: Creating your best custom player [10 points] Create a custom player using any technique you wish that plays the best game of Mancala possible. This will be the player that you enter into the class tournament. Your only restriction is that your player must make its moves in about 10 seconds (you don't need to

get fancy with timers or anything, but if it runs significantly longer than that, it will be disqualified from the tournament). Next, choose a name for your player. You should rename both the MancalaPlayer subclass and the Player.py file to match your player's name. (This is so they can be easily identified in the tournament). I will hold a tournament of these players (the finals to be held in class, time permitting), and the winner will receive a prize of some sort. Optional Extra Credit #1 [up to 2 points]: Improve on the Mancala GUI that I provided. You can start with my code and add to it, or simply start over from scratch. Submit your GUI files, clearly named and commented, with the rest of your assignment. Optional Extra Credit #2 [up to 3 points]: As described above, my minimax implementation does not take into account the fact that a player gets another move if his or her last stone ends in the player's own Mancala. Write a new minimax function, called "minimaxbonus" and a new alpha-beta pruning function, called "abprunebonus", that takes into account that a player gets another move on their turn if they land in their own Mancala with their last stone. You should also be sure to provide test cases in a file called "bonus.txt" that shows that your new algorithms do indeed work as expected (this is somwhat tricky, but important). What to submit: YourPlayer.py: (i.e. the renamed "Player.py" file) The file containing all the code you have written, including your score function, your alpha beta pruning algorithm and your custom player. ABcorrectness.txt: Your analysis of the correctness of your alpha-beta pruning algorithm, as described above. boardscore.txt: Your analysis of how you chose your board score function, as described above Be sure to include both your name and your partner's name on all files. When you are done, place all of the above listed files in a folder named in the manner described in the syllabus (e.g., Sood_1 for my first assignment) and put them in the dropbox before the due date/time listed at the top of this assignment.