Homework 11 Due ( MT sections ) ( WTh sections ) at midnight Sun., 11/14 Mon., 11/15 Problems

Slides:



Advertisements
Similar presentations
1.A computer game is an example of A.system software; B.a compiler; C.application software; D.hardware; E.none of the above. 2.JVM stands for: A.Java Virtual.
Advertisements

Computer Programming Lab(7).
"Intelligent" CS 5 An object is structured data that is alive, responsible, and intelligent. Sound too friendly? This week’s objects and classes will be.
Computers playing games. One-player games Puzzle: Place 8 queens on a chess board so that no two queens attack each other (i.e. on the same row, same.
Computer Programming Lab 8.
Logic & program control part 3: Compound selection structures.
Big Java by Cay Horstmann Copyright © 2008 by John Wiley & Sons. All rights reserved. It is common to use two nested loops when filling or searching: for.
Chapter 13 ARRAY LISTS AND ARRAYS. CHAPTER GOALS To become familiar with using array lists to collect objects To learn about common array algorithms To.
Chapter 13 ARRAY LISTS AND ARRAYS CHAPTER GOALS –To become familiar with using array lists to collect objects –To learn about common array algorithms –To.
CS110 Programming Language I Lab 10: Arrays I Computer Science Department Spring 2014.
Overview Reference parameters Documenting functions A game of craps. Design, code, test and document.
Homework 6 Due ( MT sections ) ( WTh sections ) about midnight Sun., 10/12 Mon., 10/13 Problems
Two examples of Problem Solving in Programming H. Chad Lane University of Pittsburgh CS7: Introduction to Programming.
HW 6: Problems 2&3 Simulating Connect 4.
Intelligent CS 5 ? HW 11 (1 problem !) M/T sections W/Th sections due Sunday, 11/14 at midnight due Monday, 11/15 at midnight Recitation for HW11 -- Friday.
Homework 14 Due ( MT sections ) ( WTh sections ) at midnight Sun., 12/7 Mon., 12/8 Problems
CompSci Recursion & Minimax Playing Against the Computer Recursion & the Minimax Algorithm Key to Acing Computer Science If you understand everything,
COMP 14 Introduction to Programming Mr. Joshua Stough February 16, 2005 Monday/Wednesday 11:00-12:15 Peabody Hall 218.
Homework 4 Due ( MT sections ) ( WTh sections ) at midnight Sun., 9/29 Mon., 9/30 Problems
CS 121 – Intro to Programming:Java - Lecture 3 Announcements Course home page: Owl due Friday;
CPS 2231 Computer Organization and Programming Instructor: Tian (Tina) Tian.
Assertions Program correctness. Assertions Java statement – enables you to assert an assumption about your program. – An assertion contains a Boolean.
CS 5 HW 12 (2 problems) M/T sections W/Th sections due Sunday, 11/21 at midnight due Monday, 11/22 at midnight Recitation for HW12 -- Friday 8:00am Looking.
Nelson Series Talk Wed, 11/10 7:00 pm Security, Liberties and Trade-offs in the War on Terrorism Since 9/11, we have enacted the Patriot Act, tighter screening.
Def tomorrow(self): """Changes the calling object so that it represents one calendar day after the date it originally represented. """ if self.month in.
By Nicholas Policelli An Introduction to Java. Basic Program Structure public class ClassName { public static void main(String[] args) { program statements.
CSC 204 Programming I Loop I The while statement.
CSc2310 tutoring session, week 8 Fall, 2012 Haidong Xue 5:30pm—8:30pm 10/23/2012 and 10/24/2012 -Using Exceptions -Homework 4.
CS1101X: Programming Methodology Recitation 3 Control Structures.
Homework 3 Due ( MT sections ) ( WTh sections ) at midnight Sun., 9/21 Mon., 9/22 Problems
This week in CS 5 HW 9 (2 problems) M/T sections W/Th sections due Sunday, 11/4 at midnight due Monday, 11/5 at midnight Recitation for HW9 -- Friday 11/2.
Homework 5 Due ( MT sections ) ( WTh sections ) at midnight Sun., 10/6 Mon., 10/7 Problems
Homework 9 Due ( M & T sections ) ( W & Th sections ) at midnight Sun., 11/3 Mon., 11/4 Problems
CS 5 Finale Databases graded… Exam/grading information CS 5 looking back/ahead CS 5 evaluations What do these have in common?
COP Structures Instructor: Diego Rivera-Gutierrez I’m back baby!
Discussion 4. Labs public MyPoint(double xInit, double yInit ) { MyPoint p = new MyPoint(0, 0); } ClassProblem.java recursive java.lang.StackOverflowError.
Introduction to Java Lecture Notes 3. Variables l A variable is a name for a location in memory used to hold a value. In Java data declaration is identical.
HW 6: Problems 2 & 3 Simulating Connect 4. HW 6: Overview Connect 4: Variation of Tic-Tac-Toe – Board: Vertical 7x6 – Two players take alternating move.
CS110 Programming Language I Lab 4: Control Statements I Computer Science Department Spring 2014.
School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae, VUW AI for games: min-max search COMP #
Classes and Objects CS177 Rec 10. Announcements Project 4 is posted ◦ Milestone due on Nov. 12. ◦ Final submission due on Nov. 19. Exam 2 on Nov. 4 ◦
Homework 8 Due ( MT sections ) ( WTh sections ) at midnight Sun., 10/28 Mon., 10/29 Problems Reading is under week 7, however.
Code Compression the benefits of looping... Today in CS 5 HW 4 - (3 problems) M/T sections W/Th sections due Sunday, 9/26 at midnight due Monday, 9/27.
CSE 143 Lecture 18 More Recursive Backtracking slides created by Marty Stepp
CS Class 15 Today  More practice with arrays  Introduction to Multi-dimensional arrays Announcements  Programming project #4 due 10/23 by midnight.
Chomp. How is the game played Human player goes first choose a square, all to the right and down are “eaten” computer takes a turn whoever is forced to.
Print Row Function void PrintRow(float x[ ][4],int i) { int j; for(j=0;j
When constructing a two-dimensional array, specify how many rows and columns are needed: final int ROWS = 3; final int COLUMNS = 3; String[][] board =
Midterm 2 Review Notes on the CS 5 midterm Take-home exam due by 5:00 pm Sunday evening (11/14) Hand in your solutions under the door of my office, Olin.
Homework 10 Due ( MT sections ) ( WTh sections ) at midnight Sun., 11/10 Mon., 11/11 Problems
Nelson Series Talk Wed, 10/13 7:00 pm HMC’s Galileo Auditorium On Robots, Probability, and Artificial Intelligence This talk will expose the audience.
EECS 110: Lec 15: Classes and Objects (2)
Values vs. References Lecture 13.
Homework 12 Sun., 11/24 Due Mon., 11/25 Problems (2 of them)
CS1020 – Data Structures And Algorithms 1 AY Semester 2
Chapter 8 – Arrays and Array Lists
Sit-In Lab 1 Ob-CHESS-ion
Multi-dimensional Array
Intelligent CS 5 ? This week's objects will be more adversarial…
Control Statement Examples
Homework 2 Sun., 9/12 Due Mon., 9/13 Problems available on-line
CSC 113 Tutorial QUIZ I.
SELECTION STATEMENTS (2)
HW 6: Problems 2 & 3 Simulating Connect 4.
class PrintOnetoTen { public static void main(String args[]) {
Lecture Notes – Week 2 Lecture-2
HW 6: Problems 2 & 3 Simulating Connect 4.
CSE 143 Lecture 18 More Recursive Backtracking
CSE 143 Lecture 18 More Recursive Backtracking
EECS 110: Lec 15: Classes and Objects (2)
Presentation transcript:

Homework 11 Due ( MT sections ) ( WTh sections ) at midnight Sun., 11/14 Mon., 11/15 Problems Tutors available Fri., Sat. afternoons Lac Lab and Parsons (1-4) Sunday afternoons Lac Lab and Parsons (1-4) Sunday evenings Lac Lab and Parsons (8-12) Monday evenings Lac Lab and Parsons (8-12) names and hours linked from the CS 5 Syllabus

Tutors available -- contact information

char checker Picture of a Player object Player int lookahead Player playerForX Player(char ch, int lk, int tbk) int tiebreakType char getChecker() char me() char opp()void printScores() double evaluate(Board b) double[] ply0,1,2,3,4,N(Board b) double[] plyHuman(Board b) int breaktie(double[] s) … int go(Board b)

Problem 1: Methods to write class Player public double tournamentEvaluate(Board b) public double[] findScores(Board b) public int plyHuman(Board b) public double[] ply0(Board b) (ply1, ply2, ply3, ply4, (plyN) ) public int breaktie(double[] s) Methods class Board public void removeMove(int c) public boolean isOver() New Methods public double evaluate(Board b) small methods: constructor, me(), you(), printScores public void clear() extra credit no “go” extra credit

Problem 1: Outline mainwhile find the score for each column find the maximum score break ties return a single move create an array of 7 doubles s s max = 100 (right, left, random) 3 (column 3) ply tie bkr

Hw10 class CS5App { public static void main(String[] args) { H.pl("Hi! Welcome to Connect 4..."); int R = H.ni(); int C = H.ni(); Board b = new Board(R,C); char player = 'X'; while (true) { b.print(); int c = H.ni(); // gets next move b.addMove(c,player); if (b.winsFor(player)) break; if (player == 'X') player = '0'; else player = 'X'; } // end of while } Hw11 Player px = new Player(‘X’,lk,tb); Player po = new Player(‘O’,lk,tb); Player player = px; if (player == px) player = po; else player = px; player.me() Changes player.me() 6 7

Player px = new Player(‘X’,lk,tb); Player po = new Player(‘O’,lk,tb); Player player = px; if (player == px) player = po; else player = px; Player px Player po Details ‘X’ ply tiebreaker Details ‘O’ ply tiebreaker Player player

Choosing a move 1) Find scores at appropriate lookahead… 2) Print the scores. 3) Break ties to determine the next move. ply0 : 0 ply of lookahead ply1 : 1 ply of lookahead ply2,3,4 : 2,3,4 ply of lookahead plyHuman : ask the user printScores : prints the scores to each column breaktie : chooses ONE maximum score findScores chooses one of these methods to run

class Player { public double[] findScores(Board b) { returns the appropriate set of seven scores char checker int lookahead int tiebreakType findScores

plyHuman class Player { // returns a set of scores! // with the user choosing a col public double[] plyHuman(Board b) { ??????? s 0c need to prompt for input need a valid score need to support “hints”

class Player { public double[] ply0(Board b) { double[] s = new double[7]; for (int c=0 ; c<7 ; ++c) { if (b.allowsMove(c)) { s[c] = } else s[c] = } return s; } ply0

Looking ahead … 0 ply: 2 ply:3 ply: random (but legal) choice of move ! (1) player will win (2) player will avoid losing (3) player will set up a win by forcing the opponent to avoid losing 1 ply: X ’s move

2-ply scores for O col 0col 1col 2col 3col 4col 5col 6 1-ply scores for X col 0col 1col 2col 3col 4col 5col 6

3-ply scores for X col 0col 1col 2col 3col 4col 5col 6 2-ply scores for O col 0col 1col 2col 3col 4col 5col 6

‘X’ ‘O’ new‘X’ Col 6 Col 5 Col 4 Col 3 Col 2 Col 1 Col 0 b Choosing the best move (1) For each possible move (2) Create new boards (3) Evaluate and return the seven scores received

class Player { public double[] ply1(Board b) { double[] s = new double[7]; for (int c=0 ; c<7 ; ++c) { if (b.allowsMove(c)) { s[c] = evaluate(b); } else s[c] = -1.0; } return s; } ply1 This is copied directly from the ply0 code!

evaluate class Player { // returns the appropriate score for b // remember: all of Player’s methods are available public double evaluate(Board b) { for a win -1.0 for an invalid move 0.0 for a loss 50.0 for a “tie” Improvements? Write tournamentEvaluate for Ex. Cr.! if ( ) return 100.0; else if ( ) return 0.0; else return 50.0; not possible in evaluate !

class Player { public double[] ply2(Board b) { double[] s = new double[7]; for (int c=0 ; c<7 ; ++c) { if (b.allowsMove(c)) { s[c] = evaluate(b); } else s[c] = -1.0; } return s; } ply2 This is copied directly from the ply0 code!

breaktie class Player { // returns a column to move // public int breaktie(double[] s) { s 0c123456

removeMove class Board { // removes a move from col c // public void removeMove(c) { XOOX X this.data 0 column row XOOX X XOOX X XOOX X XOOX X XOOX X

Good luck on this!

double[] s = player.findScores(b); player.printScores(s); int c = player.breaktie(s);