/**** , [ MatrixGame.cpp ], Copyright (c) 2007 Universite d'Orleans - Arnaud Lallouet Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *************************************************************************/ #include /* pour srand, rand et RAND_MAX */ #include /* pour time */ #include /* pour pow */ #include #include "gecode/minimodel.hh" #include "gecode/int/element.hh" #include "qsolver.hh" #include "implicative.hh" #define UNIVERSAL true #define EXISTENTIAL false // The Matrix game consists in a square boolean matrix of size 2^depth. First player cuts it vertically in two parts and removes one half, // while secodn player do the same, but cutting the matrix horizontally. The game ends when there are only one cell left in the matrix. // If this last cell has value 1, the first player wins. If it has value 0, the second player wins. // The present model of this game is pure QBF, that QeCode can handle (though not as fast as QBF solvers...) using namespace MiniModel; int main (int argc, char * const argv[]) { int depth = 5; // Size of the matrix is 2^depth. Larger values may take long to solve... int nbDecisionVar = 2*depth; int nbScope = nbDecisionVar+1; bool* qtScopes = new bool[nbScope]; for (int i=0;i=0; i--) access[i]=access[i+2]*2; // debug for (int i=0; i