Difference between revisions of "Computer Science/61b"

From lensowiki
Jump to: navigation, search
m (Methods: rm stray questionmark)
(Gameboard & chips ADT: -bb – updating, cleanup, formatting)
Line 2: Line 2:
 
Members: Paul, -bb; Andrew, -fe; Jordan, -er <!-- borokhov, vo, berk -->
 
Members: Paul, -bb; Andrew, -fe; Jordan, -er <!-- borokhov, vo, berk -->
 
===Gameboard & chips ADT===
 
===Gameboard & chips ADT===
  /* Paul can do this - it's a essentially a copy from the Oceans project, so it's quick */
+
  /* Paul */
  // Gameboard abstract data type
+
  // Gameboard abstract data type – Gameboard class
  // board field stores a board using an array of Chips (not that important – no one has access to this field anyway)
+
  // '''fields''': public static final int SDEPTH = 10, given to no-depth constructor
  // methods are required to retrieve/store chips
+
  // '''methods''':
Gameboard class
 
fields: private Chip[] board
 
methods:
 
 
  // inserts a chip of the given color in the specified place as determined by an x, y coord pair
 
  // inserts a chip of the given color in the specified place as determined by an x, y coord pair
 
  // returns true if the insertion succeeds; false otherwise
 
  // returns true if the insertion succeeds; false otherwise
Line 20: Line 17:
 
  Chip retrieveChip(int x, int y)
 
  Chip retrieveChip(int x, int y)
 
  // returns true if the given move is valid; false otherwise
 
  // returns true if the given move is valid; false otherwise
 +
/* Verified conditions:
 +
# No chip may be placed in any of the four corners.
 +
# No chip may be placed in a goal of the opposite color.
 +
# No chip may be placed in a square that is already occupied.
 +
# A player may not have more than two chips in a connected group, whether connected orthogonally or diagonally. */
 
  boolean validMove(Move m)
 
  boolean validMove(Move m)
    // returns true if the chip cluster (if any) is small enough to permit a chip insertion at the given location as determined by an x, y coord pair; false otherwise
 
  ->could be inside or another method: boolean checkClusterSize(int x, int y)
 
 
   
 
   
  // abstract data type to hold information about chips
+
  // Chip abstract data type – Chip class
 
  // color field stores the chip's color as a static final int; x and y fields store the chip's x and y coords, respectively
 
  // color field stores the chip's color as a static final int; x and y fields store the chip's x and y coords, respectively
  Chip class
+
  // '''fields''': public static final int WHITE/BLACK = 1/0 (this is how we refer to colors, though I don't think anyone would need to)
fields (all private): int color, int x, int y
+
  //        public final static int DIMENSION = 8 for the dimensions of the board
public static final WHITE/BLACK = 1/0
+
// '''methods''':
  methods:
 
 
  // returns the chip's color
 
  // returns the chip's color
 
  int getColor()
 
  int getColor()

Revision as of 02:46, 29 October 2006

Project 2 modules

Members: Paul, -bb; Andrew, -fe; Jordan, -er

Gameboard & chips ADT

/* Paul */
// Gameboard abstract data type – Gameboard class
// fields: public static final int SDEPTH = 10, given to no-depth constructor
// methods:
// inserts a chip of the given color in the specified place as determined by an x, y coord pair
// returns true if the insertion succeeds; false otherwise
boolean insertChip(int color, int x, int y)
// move a given chip to a specified place as determined by an x, y coord pair
// returns true if the move succeeds; false otherwise
boolean moveChip(Chip c, int x, int y)
// performs a move and returns true/false depending on whether it succeeded
boolean performMove(int color, Move m)
// returns the Chip at a given location as determined by an x, y coord pair
Chip retrieveChip(int x, int y)
// returns true if the given move is valid; false otherwise
/* Verified conditions:
# No chip may be placed in any of the four corners. 
# No chip may be placed in a goal of the opposite color.
# No chip may be placed in a square that is already occupied.
# A player may not have more than two chips in a connected group, whether connected orthogonally or diagonally. */
boolean validMove(Move m)

// Chip abstract data type – Chip class
// color field stores the chip's color as a static final int; x and y fields store the chip's x and y coords, respectively
// fields: public static final int WHITE/BLACK = 1/0 (this is how we refer to colors, though I don't think anyone would need to)
//         public final static int DIMENSION = 8 for the dimensions of the board
// methods:
// returns the chip's color
int getColor()
// returns the x coord of the chip
int getX()
// returns the y coord of the chip
int getY()

Changes to MachinePlayer class

New fields

int color
int opponent
int depth
Gameboard board

Methods

/* Andrew */
// generates an array of Gameboards of all the possible moves from the current Gameboard g for a given player. returns an array of Gameboards
Object[][] generateMoves(Gameboard g, int color)

/* Paul */
// evaluates all possible moves to be generated from the this board using the minimax algorithm and alpha-beta pruning.
// continues searching until it reaches depth or a win, whichever comes first
Move evalTree(int color, int depth)

/* Jordan */
// evaluates the given network for a winning color
// returns a probability of winning if there is no win
// returns 999 if WHITE wins, -999 if BLACK wins
int winner(Gameboard g)