summaryrefslogtreecommitdiffstats
path: root/kmines/solver/test.cpp
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commitc90c389a8a8d9d8661e9772ec4144c5cf2039f23 (patch)
tree6d8391395bce9eaea4ad78958617edb20c6a7573 /kmines/solver/test.cpp
downloadtdegames-c90c389a8a8d9d8661e9772ec4144c5cf2039f23.tar.gz
tdegames-c90c389a8a8d9d8661e9772ec4144c5cf2039f23.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdegames@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kmines/solver/test.cpp')
-rw-r--r--kmines/solver/test.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/kmines/solver/test.cpp b/kmines/solver/test.cpp
new file mode 100644
index 00000000..dd56d7a0
--- /dev/null
+++ b/kmines/solver/test.cpp
@@ -0,0 +1,45 @@
+/** A program to test advisory library */
+
+#include "bfield.h"
+#include "headerP.h"
+
+#define W 10
+#define H 10
+
+int main(int argc, char *argv[])
+{
+ long seed = (argc<2 ? time(0) : atoi(argv[1]));
+ cout << "seed = " << seed << endl;
+
+ BaseField f(seed);
+ f.reset(W, H, 10);
+
+ KRandomSequence random(seed);
+ Coord c(random.getLong(W), random.getLong(H));
+ f.doReveal(c, 0, 0);
+
+ CoordSet sp;
+ AdviseFull::ProbabilityMap pm;
+
+ AdviseFast::FactSet facts(&f);
+ AdviseFull::adviseFull(&facts, &sp, &pm);
+
+ float pic[H][W];
+
+ for(uint i=0; i<H; ++i)
+ for(uint j=0; j<W; ++j) pic[i][j] = -1; // unknown
+ pic[c.second][c.first] = -(int)f.nbMinesAround(c);
+
+ AdviseFull::ProbabilityMap::iterator pmi;
+ for(pmi = pm.begin(); pmi != pm.end(); ++pmi)
+ pic[pmi->second.second][pmi->second.first] = pmi->first;
+
+ QString s;
+ for(uint i=0;i<H;++i) {
+ for(uint j=0;j<W;++j)
+ cout << s.sprintf("%+.02f ", pic[i][j]).latin1();
+ cout << endl;
+ }
+
+ return 0;
+}