diff options
author | Thomas Günther <tom@toms-cafe.de> | 2010-03-28 23:16:45 +0200 |
---|---|---|
committer | Thomas Günther <tom@toms-cafe.de> | 2010-03-31 00:09:02 +0200 |
commit | ec52e565f779f93f069cca2bd0bce9027a5fcf77 (patch) | |
tree | d41848361559177449ff41b89c39274d783a78ef | |
parent | 536aec97f0b6e7f7d09083c7c7421f1ae5de0ea1 (diff) | |
download | vdr-plugin-sudoku-ec52e565f779f93f069cca2bd0bce9027a5fcf77.tar.gz vdr-plugin-sudoku-ec52e565f779f93f069cca2bd0bce9027a5fcf77.tar.bz2 |
Added method Pos::interacts_with
-rw-r--r-- | HISTORY | 1 | ||||
-rw-r--r-- | puzzle.cpp | 7 | ||||
-rw-r--r-- | puzzle.h | 4 |
3 files changed, 7 insertions, 5 deletions
@@ -92,3 +92,4 @@ ____-__-__: Version 0.3.5 - Changed repository from subversion to git. - Removed subversion keywords ($Id). - Added support for VDR >= 1.7.13 (Make.global). +- Added method Pos::interacts_with. @@ -1,7 +1,7 @@ /* * Sudoku: A plug-in for the Video Disk Recorder * - * Copyright (C) 2005-2008, Thomas Günther <tom@toms-cafe.de> + * Copyright (C) 2005-2010, Thomas Günther <tom@toms-cafe.de> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -196,7 +196,7 @@ void Puzzle::set(Pos pos, unsigned int number) // Refresh possible numbers of all affected cells. for (Pos p = Pos::first(); p <= Pos::last(); p = p.next()) - if (p.col() == pos.col() || p.row() == pos.row() || p.reg() == pos.reg()) + if (p.interacts_with(pos)) compute_numbers(p); } } @@ -362,8 +362,7 @@ void Puzzle::compute_numbers(Pos pos) // Disable numbers found in row, column or region. for (Pos p = Pos::first(); p <= Pos::last(); p = p.next()) - if (p != pos && - (p.col() == pos.col() || p.row() == pos.row() || p.reg() == pos.reg())) + if (p.interacts_with(pos)) numbers[pos][get(p)] = false; // Count the possible numbers. @@ -1,7 +1,7 @@ /* * Sudoku: A plug-in for the Video Disk Recorder * - * Copyright (C) 2005-2008, Thomas Günther <tom@toms-cafe.de> + * Copyright (C) 2005-2010, Thomas Günther <tom@toms-cafe.de> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -71,6 +71,8 @@ namespace Sudoku Pos next_col() const { return col() < DIM-1 ? pos + 1 : pos; } Pos prev_row() const { return row() > 0 ? pos - DIM : pos; } Pos next_row() const { return row() < DIM-1 ? pos + DIM : pos; } + bool interacts_with(Pos other) const { return pos != other && + (col() == other.col() || row() == other.row() || reg() == other.reg()); } }; |