Difference between revisions of "Computer Science/61b"
(updating) |
|||
Line 1: | Line 1: | ||
==Project 2 modules== | ==Project 2 modules== | ||
Members: Paul, -bb; Andrew, -fe; Jordan, -er <!-- borokhov, vo, berk --> | Members: Paul, -bb; Andrew, -fe; Jordan, -er <!-- borokhov, vo, berk --> | ||
+ | ==Gameboard & chips ADT== | ||
/* Paul can do this - it's a essentially a copy from the Oceans project, so it's quick */ | /* Paul can do this - it's a essentially a copy from the Oceans project, so it's quick */ | ||
// Gameboard abstract data type | // Gameboard abstract data type | ||
Line 14: | Line 15: | ||
// returns true if the move succeeds; false otherwise | // returns true if the move succeeds; false otherwise | ||
boolean moveChip(Chip c, int x, int y) | 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 | // returns the Chip at a given location as determined by an x, y coord pair | ||
Chip retrieveChip(int x, int y) | Chip retrieveChip(int x, int y) | ||
Line 25: | Line 28: | ||
Chip class | Chip class | ||
fields (all private): int color, int x, int y | fields (all private): int color, int x, int y | ||
− | public static final WHITE/BLACK = 1/ | + | public static final WHITE/BLACK = 1/0 |
methods: | methods: | ||
// returns the chip's color | // returns the chip's color | ||
Line 34: | Line 37: | ||
int getY(Chip c) | int getY(Chip c) | ||
− | + | ==Changes to MachinePlayer class== | |
− | + | ===New fields=== | |
− | + | int color | |
− | + | int depth | |
+ | Gameboard board | ||
+ | |||
+ | ===Methods=== | ||
/* Andrew? */ | /* 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 | // generates an array of Gameboards of all the possible moves from the current Gameboard g for a given player. returns an array of Gameboards | ||
Gameboard[] generateMoves(Gameboard g, int color) | Gameboard[] generateMoves(Gameboard g, int color) | ||
+ | ---- | ||
/* Paul? */ | /* Paul? */ | ||
// evaluates an array of gameboards using the minimax algorithm and alpha-beta pruning. | // evaluates an array of gameboards using the minimax algorithm and alpha-beta pruning. | ||
// if necessary, generates additional move levels (i.e. if none of the gameboards in this array result in a win) | // if necessary, generates additional move levels (i.e. if none of the gameboards in this array result in a win) | ||
Move evalTree(Gameboard[] arr) | Move evalTree(Gameboard[] arr) | ||
+ | ---- | ||
/* Jordan? */ | /* Jordan? */ | ||
// evaluates the given network for a winning color | // evaluates the given network for a winning color | ||
− | // returns the winning color (as Chip.color), | + | // returns the winning color (as Chip.color), -10 if there is no winner |
+ | // '''NOTE''': we need to figure out how to rate a board that doesn't win and we're already at the lowest level – some sort of probability technique, how many connections there are with the current chips, etc.... | ||
int winner(Gameboard g) | int winner(Gameboard g) |
Revision as of 03:33, 18 October 2006
Contents
Project 2 modules
Members: Paul, -bb; Andrew, -fe; Jordan, -er
Gameboard & chips ADT
/* Paul can do this - it's a essentially a copy from the Oceans project, so it's quick */ // Gameboard abstract data type // board field stores a board using an array of Chips (not that important – no one has access to this field anyway) // methods are required to retrieve/store chips 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 // 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 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 // 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 (all private): int color, int x, int y public static final WHITE/BLACK = 1/0 methods: // returns the chip's color int getColor(Chip c) // returns the x coord of the chip int getX(Chip c) // returns the y coord of the chip int getY(Chip c)
Changes to MachinePlayer class
New fields
int color 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 Gameboard[] generateMoves(Gameboard g, int color)
/* Paul? */ // evaluates an array of gameboards using the minimax algorithm and alpha-beta pruning. // if necessary, generates additional move levels (i.e. if none of the gameboards in this array result in a win) Move evalTree(Gameboard[] arr)
/* Jordan? */ // evaluates the given network for a winning color // returns the winning color (as Chip.color), -10 if there is no winner // NOTE: we need to figure out how to rate a board that doesn't win and we're already at the lowest level – some sort of probability technique, how many connections there are with the current chips, etc.... int winner(Gameboard g)