summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Günther <tom@toms-cafe.de>2010-03-28 23:16:45 +0200
committerThomas Günther <tom@toms-cafe.de>2010-03-31 00:09:02 +0200
commitec52e565f779f93f069cca2bd0bce9027a5fcf77 (patch)
treed41848361559177449ff41b89c39274d783a78ef
parent536aec97f0b6e7f7d09083c7c7421f1ae5de0ea1 (diff)
downloadvdr-plugin-sudoku-ec52e565f779f93f069cca2bd0bce9027a5fcf77.tar.gz
vdr-plugin-sudoku-ec52e565f779f93f069cca2bd0bce9027a5fcf77.tar.bz2
Added method Pos::interacts_with
-rw-r--r--HISTORY1
-rw-r--r--puzzle.cpp7
-rw-r--r--puzzle.h4
3 files changed, 7 insertions, 5 deletions
diff --git a/HISTORY b/HISTORY
index 81dee19..19513d0 100644
--- a/HISTORY
+++ b/HISTORY
@@ -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.
diff --git a/puzzle.cpp b/puzzle.cpp
index 120db9e..3571d39 100644
--- a/puzzle.cpp
+++ b/puzzle.cpp
@@ -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.
diff --git a/puzzle.h b/puzzle.h
index ad47cf1..3bc6feb 100644
--- a/puzzle.h
+++ b/puzzle.h
@@ -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()); }
};