General Computer Science for Engineers CISC 106 Lecture 08 James Atlas Computer and Information Sciences 07/01/2009.

Slides:



Advertisements
Similar presentations
A Case Study  Some Advice on How to Go about Solving Problems in Prolog  A Program to Play Connect-4 Game.
Advertisements

CS 206 Introduction to Computer Science II 03 / 27 / 2009 Instructor: Michael Eckmann.
General Computer Science for Engineers CISC 106 Lecture 01 James Atlas Computer and Information Sciences 9/2/2009.
CHAPTER 10 FUN AND GAMES Group 1: Xiangling Liu.
Graphs Graphs are the most general data structures we will study in this course. A graph is a more general version of connected nodes than the tree. Both.
Stacks CS 3358 – Data Structures. What is a stack? It is an ordered group of homogeneous items of elements. Elements are added to and removed from the.
Introducing While loops (and random numbers too) Alice.
CS 206 Introduction to Computer Science II 11 / 11 / Veterans Day Instructor: Michael Eckmann.
Maths for Computer Graphics
General Computer Science for Engineers CISC 106 Lecture 19 Dr. John Cavazos Computer and Information Sciences 04/06/2009.
General Computer Science for Engineers CISC 106 James Atlas Computer and Information Sciences 10/23/2009.
General Computer Science for Engineers CISC 106 James Atlas Computer and Information Sciences 10/18/2009.
General Computer Science for Engineers CISC 106 Final Exam Review Dr. John Cavazos Computer and Information Sciences 05/18/2009.
Liang, Introduction to Programming with C++, Second Edition, (c) 2010 Pearson Education, Inc. All rights reserved Chapter 8 Multidimensional.
CS 206 Introduction to Computer Science II 11 / 03 / 2008 Instructor: Michael Eckmann.
General Computer Science for Engineers CISC 106 Lecture 08
CS 206 Introduction to Computer Science II 11 / 05 / 2008 Instructor: Michael Eckmann.
General Computer Science for Engineers CISC 106 Lecture 25 Dr. John Cavazos Computer and Information Sciences 04/20/2009.
CS 206 Introduction to Computer Science II 03 / 25 / 2009 Instructor: Michael Eckmann.
General Computer Science for Engineers CISC 106 Lecture 07 James Atlas Computer and Information Sciences 9/18/2009.
CS 206 Introduction to Computer Science II 11 / 09 / 2009 Instructor: Michael Eckmann.
Algorithms All pairs shortest path
General Computer Science for Engineers CISC 106 Lecture 09 James Atlas Computer and Information Sciences 9/25/2009.
CS 206 Introduction to Computer Science II 03 / 30 / 2009 Instructor: Michael Eckmann.
General Computer Science for Engineers CISC 106 Lecture 08 James Atlas Computer and Information Sciences 9/21/2009.
General Computer Science for Engineers CISC 106 Lecture 18 Dr. John Cavazos Computer and Information Sciences 3/27/2009.
General Computer Science for Engineers CISC 106 James Atlas Computer and Information Sciences 10/21/2009.
MATRICES. Matrices A matrix is a rectangular array of objects (usually numbers) arranged in m horizontal rows and n vertical columns. A matrix with m.
Computer Science 112 Fundamentals of Programming II Graph Algorithms.
Recursion Chapter 5.
General Computer Science for Engineers CISC 106 Lecture 07 James Atlas Computer and Information Sciences 06/29/2009.
Announcements.
Computer Science Department Data Structure & Algorithms Lecture 8 Recursion.
Two dimensional arrays in Java Computer Science 3 Gerb Objective: Use matrices in Java.
1 N -Queens via Relaxation Labeling Ilana Koreh ( ) Luba Rashkovsky ( )
Multidimensional Array Sample Projects. Grading Program Objective: write a program that grades multiple-choice test.
Announcements This Wednesday, Class and Labs are cancelled! The last lab is due this Wednesday … how many people are planning on doing it? Finally posted.
Matrices Matrices A matrix (say MAY-trix) is a rectan- gular array of objects (usually numbers). An m  n (“m by n”) matrix has exactly m horizontal.
2009/9 1 Matrices(§3.8)  A matrix is a rectangular array of objects (usually numbers).  An m  n (“m by n”) matrix has exactly m horizontal rows, and.
The all-pairs shortest path problem (APSP) input: a directed graph G = (V, E) with edge weights goal: find a minimum weight (shortest) path between every.
Module #9: Matrices Rosen 5 th ed., §2.7 Now we are moving on to matrices, section 7.
1 Data Structures CSCI 132, Spring 2014 Lecture 17 Backtracking.
Matrices: Simplifying Algebraic Expressions Combining Like Terms & Distributive Property.
1 Arrays of Arrays An array can represent a collection of any type of object - including other arrays! The world is filled with examples Monthly magazine:
General Computer Science for Engineers CISC 106 Lecture 13 - Midterm Review James Atlas Computer and Information Sciences 10/02/2009.
Computer Science: A Structured Programming Approach Using C1 8-7 Two-Dimensional Arrays The arrays we have discussed so far are known as one- dimensional.
Warship C++: An entity of Battleship
CSE 143 Lecture 13 Recursive Backtracking slides created by Ethan Apter
Tutorial 9 Iteration. Reminder Assignment 8 is due Wednesday.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 122 – Data Structures Sorting.
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.
Programming for Art: Arrays – 2D ART 315 Dr. J. R. Parker Art/Digital Media Lab Lec 16 Fall 2010.
90-723: Data Structures and Algorithms for Information Processing Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 7: Graphs Data Structures.
Introduction to programming in java Lecture 23 Two dimensional (2D) Arrays – Part 3.
Practical Session 9 Computer Architecture and Assembly Language.
1 Tirgul 11: Recursion & Backtracking. 2 Elements of a recursive solution (Reminder) A base case that is so simple we need no computation to solve it.
13.4 Product of Two Matrices
Lesson 5 Functions I A function is a small program which accomplishes a specific task. For example, we invoke (call) the function, sqrt(x), in the library.
Sit-In Lab 1 Ob-CHESS-ion
LOOPS.
Control Structure Senior Lecturer
Introduction to Matrices
2.2 Introduction to Matrices
Computer Architecture and Assembly Language
Programming Languages
Tic Tac Toe application
Some Assembly (Part 2) set.html.
Computer Architecture and Assembly Language
Matrices and Determinants
General Computer Science for Engineers CISC 106 Lecture 15
Presentation transcript:

General Computer Science for Engineers CISC 106 Lecture 08 James Atlas Computer and Information Sciences 07/01/2009

Project 1 On Sakai/course website Shark and goldfish simulator Teams of 3-5 Form team by July 6, 9:00pm Complete project due July 20 Functions that need to be implemented are listed

Shark (X) vs Goldfish (O) O ---O O O X O

Functions %Make the board. Make the shark and position the shark. %Calls play and makeBoard function [] = startShark(rows, cols) %Recursive function that implements top-level algorithm. %oldShark is a shark with the previous position. %Calls: print, plotBoard, getClosestGoldfish, moveToGoldfish, eatGoldfish function [] = play(board, shark, oldShark) %Goldfish disappears from board, shark moves into former goldfish location. %Calls: function [newBoard newShark] = eatGoldfish(board, goldfishCoords, shark) %Prints an ascii version of board at interpreter prompt, showing all %simulated items. function [] = print(board, shark) %Plots board, showing all simulated items. %Calls: plotSquare function [] = plotBoard(board, shark, oldShark)

Functions cont. %Plots a single square on board. %Calls: patch function [] = plotSquare(row, col, color) %Shark moves one square at a time, horizontally or vertically, until %shark is adjacent to goldfish. Returns updated copy of shark. %Calls: isAdjacent, moveOneSquare, print, plotBoard function newShark = moveToGoldfish(board, goldfishCoords, shark) %Move shark one square closer to coords. New shark location must be a %legal, unoccupied square. %Calls: isLegalMove function [canMove newShark] = moveOneSquare(board, coords, shark) %Returns true iff board is empty at proposed position and position is %valid for this board. %Calls: function legal = isLegalMove(board, proposedMove)

Functions cont. %Returns true iff coords and shark position are vertically or %horizontally adjacent. %Calls: function flag = isAdjacent(coords, shark) %For every element of the board matrix, if the element of %the matrix is GOLDFISH, then calculate a distance. Keep track of %the minimum distance so far AND the coords of the min distance. If no %goldfish is found, isGoldfish is false. Otherwise, coords holds the row and col %coordinates of the min distance goldfish. %Calls: distance function [isGoldfish coords] = getClosestGoldfish(board, shark) %Takes the row, column coordinates of two points on the board and returns %the distance between them. %Calls: function out = distance(x1, y1, x2, y2) %Makes a matrix of the dimension parameters. Randomly places goldfish in %about five percent of the board (that is, each square on the board has a %five percent chance of being goldfish). %Calls: function board = makeBoard(rows, cols)

Each team has 3 members designated as librarian, recorder, and team leader. Grading: 1/3 individual work, 1/3 team accomplishments (with blind rating), 1/3 questions on midterm/exam about the project