Project 1: A Game of Greed

Similar documents
Red Dragon Inn Tournament Rules

BOOM! subtract 15. add 3. multiply by 10% round to. nearest integer. START: multiply by 2. multiply by 4. subtract 35. divide by 2

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

Official Skirmish Tournament Rules

Determine the Expected value for each die: Red, Blue and Green. Based on your calculations from Question 1, do you think the game is fair?

Presentation by Toy Designers: Max Ashley

HW4: The Game of Pig Due date: Thursday, Oct. 29 th at 9pm. Late turn-in deadline is Tuesday, Nov. 3 rd at 9pm.

HW4: The Game of Pig Due date: Tuesday, Mar 15 th at 9pm. Late turn-in deadline is Thursday, Mar 17th at 9pm.

MLAG BASIC EQUATIONS Tournament Rules

Probability Homework Pack 1

Mantic Kings of War Adepticon Tournament Rules 2014

Tournament Rules 1.6 Updated 10/6/2014

Cycle Roulette The World s Best Roulette System By Mike Goodman

Introduction. Table of Contents

ARMY LISTS AND CONSTRUCTION PREPARATION SPORTSMANSHIP. Tournament Guidelines

NASPA Official Tournament Rules: Player Edition

Chess Style Ranking Proposal for Run5 Ladder Participants Version 3.2

Funny Money. The Big Idea. Supplies. Key Prep: What s the Math? Valuing units of money Counting by 5s and 10s. Grades K-2

BIEB 143 Spring 2018 Weeks 8-10 Game Theory Lab

The 2013 Scripting Games. Competitor s Guide

EPIC ARMAGEDDON CHALLENGE

For 2 to 6 players / Ages 10 to adult

U strictly dominates D for player A, and L strictly dominates R for player B. This leaves (U, L) as a Strict Dominant Strategy Equilibrium.

An Adaptive-Learning Analysis of the Dice Game Hog Rounds

CS 1410 Final Project: TRON-41

LESSON 2. Developing Tricks Promotion and Length. General Concepts. General Introduction. Group Activities. Sample Deals

Trivia Games. All trivia questions have been researched and written by professional writers, and sources have been verified.

CS61B, Fall 2014 Project #2: Jumping Cubes(version 3) P. N. Hilfinger

Alberta 55 plus Cribbage Rules

Programming Languages and Techniques Homework 3

LESSON 8. Putting It All Together. General Concepts. General Introduction. Group Activities. Sample Deals

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

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

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

Assignment 1. Due: 2:00pm, Monday 14th November 2016 This assignment counts for 25% of your final grade.

Take one! Rules: Two players take turns taking away 1 chip at a time from a pile of chips. The player who takes the last chip wins.

Star Wars : Destiny Tournament Regulations

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

Taffy Tangle. cpsc 231 assignment #5. Due Dates

GICAA State Chess Tournament

Q: WHAT ARE THE RESIDENCY REQUIREMENTS FOR THOSE WHO PLAY TO COMPETE? A: This is event is restricted to UK and Ireland, therefore:

Mantic KoW National Final Tournament 2013

CS 371M. Homework 2: Risk. All submissions should be done via git. Refer to the git setup, and submission documents for the correct procedure.

CS Programming Project 1

CSE231 Spring Updated 04/09/2019 Project 10: Basra - A Fishing Card Game

Episode 11: A Proven Recipe to Get Out of a Slump

Lab Exercise #10. Assignment Overview

HENRY FRANCIS (EDITOR-IN-CHIEF), THE OFFICIAL ENCYCLOPEDIA OF BRIDGE

Bidding Over Opponent s 1NT Opening

The Galaxy. Christopher Gutierrez, Brenda Garcia, Katrina Nieh. August 18, 2012

TOURNAMENT GUIDELINES

Student activity sheet Gambling in Australia quick quiz

03/05/14 20:47:19 readme

Assignment #5 Yahtzee! Due: 3:15pm on Wednesday, November 14th

Name: Exam Score: /100. Exam 1: Version C. Academic Honesty Pledge

Mint Tin Mini Skulduggery

OFFICIAL RULEBOOK Version 7.2

2 Textual Input Language. 1.1 Notation. Project #2 2

Anti-Monopoly Instructions

WEAK TWOS, WEAK JUMP OVERCALLS AND WEAK JUMP SHIFTS

Texas Hold em Poker Basic Rules & Strategy

Dungeon Cards. The Catacombs by Jamie Woodhead

Make better decisions. Learn the rules of the game before you play.

Here are two situations involving chance:

SATURDAY APRIL :30AM 5:00PM

BLACKJACK Perhaps the most popular casino table game is Blackjack.

All-Stars Dungeons And Diamonds Fundamental. Secrets, Details And Facts (v1.0r3)

Competing for the Partscore. By Ron Klinger

SUMMARY OF CHANGES IN THIS VERSION VERSION EFFECTIVE 07/23/2018. Corrected typos and edited language for clarifications

Smyth County Public Schools 2017 Computer Science Competition Coding Problems

7:00PM 12:00AM

Exercises Exercises. 1. List all the permutations of {a, b, c}. 2. How many different permutations are there of the set {a, b, c, d, e, f, g}?

OFFICIAL RULEBOOK Version 10

2016 Bugeater GT Warhammer 40,000 Primer Packet. An Independent Tournament Circuit Event

Would You Like To Earn $1000 s With The Click Of A Button?

Round-robin Tournament with Three Groups of Five Entries. Round-robin Tournament with Five Groups of Three Entries

The Living Home Standard Game

Warhammer 40K Golden Rhino Tournament

Tournament Rules. Version / Effective SUMMARY OF CHANGES IN THIS VERSION. Added Appendix A: NAPD Most Wanted List, page 7

Please be sure to title your "AoS List" with your name this same mail box can get up to 200 army lists in one year.

A Rule-Based Learning Poker Player

The Game of Hog. Scott Lee

CMPT 125/128 with Dr. Fraser. Assignment 3

SIC BO ON THE MULTI TERMINALS

Assignment 5: Yahtzee! TM

Domino Games. Variation - This came can also be played by multiplying each side of a domino.

Operation Take the Hill Event Outline. Participant Requirements. Patronage Card

GETTING STARTED. STAR WARS D6: New Player Starting Guide. Become Your Character. Use Your Imagination. Keep Things Moving. Combat As Last Resort

CS 210 Fundamentals of Programming I Spring 2015 Programming Assignment 8

The 2nd Schaumburg Beach Head

B1 Problem Statement Unit Pricing

DIVISION I (Grades K-1) Common Rules

GCSE MATHEMATICS Intermediate Tier, topic sheet. PROBABILITY

Begin this assignment by first creating a new Java Project called Assignment 5.There is only one part to this assignment.

Ok, we need the computer to generate random numbers. Just add this code inside your main method so you have this:

Combinatorial Games. Jeffrey Kwan. October 2, 2017

Would You Like To Earn $1000 s With The Click Of A Button?

Girls Programming Network. Scissors Paper Rock!

SUNDAY 12 TH NOVEMBER 2017

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

Transcription:

Project 1: A Game of Greed In this project you will make a program that plays a dice game called Greed. You start only with a program that allows two players to play it against each other. You will build tools that let computer players play the game against each other, as well as tools that help you figure out how good different computer players are. Then you will write your own strategy function, which you ll use to compete against some test players I have written for you, as well as your classmates. Have fun! Rules of the game The game of Greed is a dice game between two players. The dice in question differ from regular dice in that they give numbers between 0 and 5, instead of between 1 and 6. The game begins with both players having a score of zero and proceeds in turns. The player whose turn it is can choose any number of dice to roll. They then roll those dice (all at once) and add the total of the dice to their score. If they go over 100, the other player is declared the winner. (A score of exactly 100 is acceptable.) Play then passes to the other player, who does the same. Play alternates in this manner until either one player goes over 100 and loses or a player chooses to pass. When a player passes (that is, rolls zero dice on their turn) the other player gets one more turn to roll, and then the game is over. If at that point neither player has gone over 100, the player with the higher score wins. (Ties are possible.) Step 1: experiment You should first work to understand the game. The included play function conducts a game between two human players, both typing their moves into prompts in the terminal. You should play several games with a friend (or just against yourself) to get a feel for the game. You should then look at the code for play and try to understand how it works. (It is purposefully not documented very well.) Step 2: autoplayloud We want to have programmed strategies play this game against each other, rather than just having humans play it. pr1.py contains a sample strategy, a function named sample1. This strategy, like all other strategies we will write, takes three inputs. Those inputs represent the current state of the game the strategy is playing. The strategy takes those inputs and outputs the next move (that is, how many dice to roll). The first input is an integer representing the strategy s current score. The second input is an integer representing the opponent s current

score. The third input is a Boolean indicating whether the opponent passed on their last turn, which would mean that this roll is the last of the game. You should look at the sample strategy, sample1. It is very simple it passes if it s currently ahead, and otherwise it rolls 12 dice. Unfortunately, we can t actually watch it play a game given the code currently in the file. Your job is to implement autoplayloud, which should work similarly to play, except that it conducts games between two computer strategies instead of two people. It should still print a record of the game to the terminal, but instead of asking for moves it should take as input two strategies and use those strategies to compute the move at each turn. (The strategy in the first argument should be player 1 and should go first, and the other strategy should be player 2.) To test your function, try running autoplayloud(sample1, sample1), which should conduct a game between two players each using sample1 as their strategy. An example of what this should print to the terminal is below. (It is not necessary to have autoplayloud return a value.) You can look at the code for play to get a general idea of what it should look like. Player 1: 0 Player 2: 0 It is Player 1's turn. Dice rolled: 3 4 5 2 3 2 1 0 1 5 2 4 Total for this turn: 32 Player 1: 32 Player 2: 0 It is Player 2's turn. Dice rolled: 4 2 4 2 4 1 3 1 4 0 1 5 Total for this turn: 31 Player 1: 32 Player 2: 31 It is Player 1's turn. 0 dice chosen. Dice rolled: Total for this turn: 0 Player 1: 32 Player 2: 31 It is Player 2's turn. Dice rolled: 0 3 4 1 1 0 4 2 5 0 2 2 Total for this turn: 24 Player 1: 32 Player 2: 55 Player 2 wins.

Step 3: autoplay Having the transcript of the game printed to the terminal is great when we re running one game at a time, but when we really want to know which strategy is better, we ll want to take a sample of thousands of games. To do this, create autoplay, function that does roughly the same thing as autoplayloud. The difference is that instead of printing the transcript of the game to the terminal, the simulation is done quietly. The function should return a value that indicates the winner of the game. 1 should be returned if the first player (the strategy listed in the first argument) wins, 2 if the second player wins, and 3 if there is a tie. Step 4: manygames We now want to be able to compare strategies. Any single game is going to include a lot of luck, and possibly a big advantage for one side based on who goes first. The function manygames gives us a much more reliable way to compare strategies. It takes as input two strategies (the first referred to as player 1 ) and an integer n. It then runs autoplay n times, with each player going first for half of those times (or as close as possible if n is odd). It keeps track of wins and ties, and prints a summary at the end as shown below. Player 1 wins: 496 Player 2 wins: 503 Ties: 1 You should implement manygames. You can test it using sample1. (The output above comes from running manygames(sample1, sample1, 1000) and is typical of what output from that function call should look like. Remember that there are random numbers involved here, so the output will be slightly different each time.) Step 5: another strategy Now you will write a strategy. It should behave as follows: If its current score is no more than 50, it should roll 30 dice If it s current score is between 51 and 80, it should roll 10 dice If the score is above 80, it should pass This should be written in the function sample2. You should then experiment to see how it compares to sample1. (You should find that in large samples it consistently beats sample1. If you don t, you have an error somewhere.)

Step 6: improve One thing that s very clear about any good strategy is that it will never roll when its score is already 100. (Such a role would risk going over and losing, and it couldn t possibly help.) Unfortunately, some strategies might roll even in this situation. Write the function improve so that it adds this check to another function. That is, improve should take a strategy function as input, and it should output another strategy function. The output should behave exactly as the input strategy would, except that why the player s score is 100, it should pass, regardless of what the input strategy would have done. Step 7: compete Now it s time for the big project, writing your own strategy. This one is completely up to you. It can work in any way you want, but your goal is to make the strategy as good as possible. Be creative. Try lots of things. Tweak the strategy a lot change a couple little details can have a big effect. Remember also that the difference between a decent strategy and a really good one can look like a small effect on the win percentage. Say one strategy has a 60% win rate against a given opponent, while another has a 58% win rate against the same opponent. The first might win very decisively when the two strategies compete against each other. You should try writing several strategies that take substantially different approaches and then see which one performs best. In the end, you should have one strategy that you are willing to stand behind, written in the mystrategy function of the program. The strength of that strategy will be a factor in your grade for this assignment, and it is also the strategy that will be entered for you in the class tournament. Remember, the resulting function might not be extremely long, but that doesn t mean you shouldn t put a lot of work into figure out exactly what will work best. Technical rules on how the strategies behave: The function must compute the next turn from scratch each time it is called. (In particular, you cannot write to a file to save computation from previous calls.) Similarly, you cannot compute moves in some other way and attempt to write out all possibilities in your function definition. The strategy must be pretty fast. Running pr1testing.teststrat(mystrategy, 10000) (described below) should take no more than 30 seconds. How fast things actually take obviously depends on the particular computer they are run on. The time limit is intended to not be a hindrance to most things you might reasonably do. If you re worried about your strategy taking too long, talk to me. Everything you write should be well- documented, but this is particularly true of your strategy. Write comments that explain what it is doing and (if not self- explanatory) why that is a reasonable thing to do.

Several tools have been provided to help you write your strategy. The pr1testing module, contained in pr1testing.pyc, contains ten strategies of varying quality for you to test yours against. You are not, however, allowed to look at pr1testing.pyc. (It will just look like gibberish anyway, but trying to decipher the gibberish is forbidden.) There is an import command already in the file. You can run a strategy by referring to, for example, pr1testing.test6 (for the sixth of the nine test strategies). That means that you could run manygames(mystrategy, pr1testing.test8, 10000) to see a sample of 10,000 games between your strategy and the eighth test strategy. There is also a single command, pr1testing.teststrat(mystrategy, 10000), that will run consecutive tests against all nine of the test strategies. You can also watch games between your strategy and the test strategies (or two of your strategies, two of the test strategies, etc.) using the autoplayloud function. You should try to get your strategy to beat as many of the test strategies as possible. Your strategy will not be judged by the margin of victory over the tests, just whether it beats them. (For example, it is much better to have a strategy that consistently edges out wins over all nine tests than one that decisively beats six of them but loses to the other three.) We will also hold a tournament between the strategies submitted by the class. Again, in the tournament all matches will be large runs of manygames and only who wins the match will matter to the outcome. The outcome of the tournament will not affect your grade. (Though there will be some small prizes ) Submitting You will submit your work online. There are three problems that you will see in the Project 1 problem set. The first is where you submit your main pr1.py file with everything in it. This file is not checked by the system. You will see a 0/0 score on it. (The TAs and I will be reviewing the projects by hand.) The next problem is where you should submit your strategy. This should be the same strategy from your pr1.py file, still named mystrategy. Include nothing else in a file but this one strategy definition and submit that file there. When you do so, it will be played against the test strategies one official time and you will be told how your strategy did. (This might take a minute or two, so be patient.) Each of these problems can only be submitted one time. Check your work first and be sure it is your final, correct submission before you upload it to the site. There is one more problem on the site. This is for timing your strategy. You should be able to get a rough idea on your own, but because every computer varies slightly in speed, we have created this as a central way to check that your strategy is fast enough. When you submit a strategy to this problem, it will be run and timed, and you will be told if it is fast enough. You can submit a strategy to this problem as often as you would like. It is worth no points. You should make sure you have timed your final strategy function using this before submitting it.