示例#1
0
std::string SudokuPuzzle::toString() const {
    std::ostringstream ss;

    for (auto&& row : getPuzzle()) {
        for (auto&& element : row) {
            ss << element << " ";
        }
        ss << std::endl;
    }

    return ss.str();
}
示例#2
0
int MapGenerator::findPuzzle(int count, int *x, int *y){
    for(int max_puzzle_y = 0; max_puzzle_y < 10; max_puzzle_y++){
        for(int max_puzzle_x = 0; max_puzzle_x < 10; max_puzzle_x++){
            if(getPuzzle(max_puzzle_x, max_puzzle_y) == count) {
                *x = max_puzzle_x;
                *y = max_puzzle_y;
                return 0;
            }
        }
    }
    return 0;
}
示例#3
0
int MapGenerator::makeSureLastPuzzleIsNotTooCloseToCenter(int placed_puzzles) {
    // Message("make_sure_last_puzzle_is_not_too_close_to_center(%d)\n", placed_puzzles);
    int max_puzzle_x = 0, max_puzzle_y = 0;
    findPuzzle(placed_puzzles-1, &max_puzzle_x, &max_puzzle_y);
    
    if(MapGenerator::GetDistanceToCenter(max_puzzle_x, max_puzzle_y) < 3) {
        for(int y=0; y < 10; y++) {
            for(int x=0; x < 10; x++) {
                if(getPuzzle(x, y) >= 0
                   && MapGenerator::GetDistanceToCenter(x, y) >= 3
                   && (x != max_puzzle_x || y != max_puzzle_y)) {
                    int replacement_puzzle = getPuzzle(x, y);
                    setPuzzle(max_puzzle_x, max_puzzle_y, replacement_puzzle);
                    setPuzzle(x, y, placed_puzzles-1);
                    
                    return 0;
                }
            }
        }
    }
    return 0;
}
示例#4
0
void GamePlayScene::doErase() {
	if (!isOnPause() && getPuzzle()->isCellEditable(m_row, m_col)) {
		AbstractCommand *cmd;
		if (isOnNote()) {
			cmd = new CmdEditCellNote(this, m_time, m_row, m_col, 0,
					m_sudoku->getCellNotes(m_row, m_col));
		} else {
			cmd = new CmdEditCellValue(this, m_time, m_row, m_col, 0,
					m_sudoku->getCellValue(m_row, m_col));
//			doSetCellValue(m_row, m_col, 0);
		}
		excute(cmd);
	}
//	m_puzzleLayer->resetValues();
//	m_puzzleLayer->resetColors();
//	m_inputLayer->setUndoRedoButton();
}