| rmarch11 (1) | |
|
Heres what I have so far: bool valid_location(string location) // checks to make sure the string location defines a valid spot on the board. // input : string location // output : true -> if location has length 2, the appropriate character specifices the row coordinate, // the other specifies the column coordinate, // and all coordinates are within appropriate limits. // false -> otherwise. {if (location.size() == 2 and location[ROW_INDEX] >= MIN_ROW and location[ROW_INDEX] <= MAX_ROW and location[COLUMN_INDEX] >= MIN_COLUMN and location[COLUMN_INDEX] <= MAX_COLUMN) { return true; } return false; } /*bool valid_end_move(string start_place, string end_place) // Determines if the move that the player wants to make is valid. // Assumptions: start_place is a valid location // input : string start_place -> the piece the player chose to move // string end_place -> the position the player desires to move // output : true -> if both locations are valid, the end location is open, and it only one spot away. // false -> otherwise. { if (!valid_location(end_place)) { return false; } int end_row = static_cast<int>(end_place[ROW_INDEX] - MIN_ROW); int end_col = static_cast<int>(end_place[COLUMN_INDEX] - MIN_COLUMN); if (board[end_row][end_col] != NO_ONE) { return false; } int start_row = static_cast<int>(start_place[ROW_INDEX] - MIN_ROW); int start_col = static_cast<int>(start_place[COLUMN_INDEX] - MIN_COLUMN); if ((abs(start_row - end_row) <= 1) and (abs(start_col - end_col) <= 1)) { return true; } return false; } */ //bool valid_end_move(string remove_place, string end_place) // Determines if the move that the player wants to make is valid. // Assumptions: start_place, remove_move are valid locations // input : string start_place -> the piece the player chose to move // string end_place -> the position the player desires to move // output : true -> if both locations are valid, the end location is open, and it only one spot away. // false -> otherwise. /*{ if (!valid_location(end_place,remove_place)) { return false; } int end_row = static_cast<int>(end_place[ROW_INDEX] - MIN_ROW); int end_col = static_cast<int>(end_place[COLUMN_INDEX] - MIN_COLUMN); if (board[end_row][end_col] != NO_ONE) { return false; } return false; } /*string human_move(player human) // wHERE TO MOVE PIECE, WHICH SQUARE TO REMOVE (2 LOOPS) { bool good_move; string remove_place, end_place; do { good_move = true; start_place = ask_string("Which Piece do you want to move?"); if (valid_start_move(start_place, human)) { end_place = ask_string("Where do you want to move your piece?"); if (valid_end_move(start_place, end_place)) { cout << "If you are sure you want to do that...." << endl; } else { cout << "You cannot move your piece to that location silly human!" << endl; good_move = false; } } else { cout << "You do not have a piece in that location foolish human!" << endl; good_move = false; } } while(!good_move); cout << start_place+end_place << endl; return start_place+end_place; */ //} // return; | |
|
|
|