Search Results

Search found 86 results on 4 pages for 'checkers'.

Page 1/4 | 1 2 3 4  | Next Page >

  • Checkers board structure

    - by Ockonal
    Hello guys, I'm implement checkers (game) board with python. Here is how I switch it to the need structure [8][8] array: _matrix = [] for i in xrange(8): _matrix.append( [' '] * 8 ) for row in xrange(0, 8): for col in xrange(0, 8): if _darkQuad(row, col) == True: _matrix[row][col] = '#' else: _matrix[row][col] = '-' def _darkQuad(row, col): return ((row%2) == (col%2)) def _printDebugBoard(): for row in xrange(0, 8): for col in xrange(0, 8): print _matrix[row][col] print '' This should do my board like: # - # - # - # - - # - # - # - # ... But the result is: - - - - - - - - # # # # # # # # - - - - - - - - # # # # # # # # - - - - - - - - # # # # # # # # - - - - - - - - # # # # # # # # What's wrong?

    Read the article

  • Checkers AI Algorithm

    - by John
    I am making an AI for my checkers game and I'm trying to make it as hard as possible. Here is the current criteria for a move on the hardest difficulty: 1: Look For A Block: This is when a piece is being threatened and another piece can be moved in behind it to protect it. Here is an example: Black Moves |W| |W| |W| |W| | | |W| |W| |W| |W| |W| | | |W| |W| | | | | |W| | | | | | | | | |B| | | | | |B| | | |B| |B| |B| |B| |B| |B| | | |B| |B| |B| |B| White Blocks |W| |W| |W| |W| | | |W| | | |W| |W| |W| |W| |W| |W| | | | | |W| | | | | | | | | |B| | | | | |B| | | |B| |B| |B| |B| |B| |B| | | |B| |B| |B| |B| 2: Move pieces out of danger: if any piece is being threatened, and a piece cannot block for that piece, then it will attempt to move out of the way. If the piece cannot move out of the way without still being in danger, the computer ignores the piece. 3: If the computer player owns any kings, it will attempt to 'hunt down' enemy pieces on the board, if no moves can be made that won't in danger the king or any other pieces, the computer ignores this rule. 4: Any piece that is owned by the computer that is in column 1 or 6 will attempt to go to a side. When a piece is in column 0 or 7, it is in a very strategic position because it cannot get captured while it is in either of these columns 5: It makes an educated random move, the move will not indanger the piece that is moving or any piece that is on the board. 6: If none of the above are possible it makes a random move. This question is not really specific to any language but if all examples could be in Java that would be great, considering this app is written in android. Does anyone see any room for improvement in this algorithm? Anything that would make it better at playing checkers?

    Read the article

  • MiniMax not working properly(for checkers game)

    - by engineer
    I am creating a checkers game but My miniMax is not functioning properly,it is always switching between two positions for its move(index 20 and 17).Here is my code: public double MiniMax(int[] board, int depth, int turn, int red_best, int black_best) { int source; int dest; double MAX_SCORE=-INFINITY,newScore; int MAX_DEPTH=3; int[] newBoard=new int[32]; generateMoves(board,turn); System.arraycopy(board, 0, newBoard, 0, 32); if(depth==MAX_DEPTH) { return Evaluation(turn,board);} for(int z=0;z<possibleMoves.size();z+=2){ source=Integer.parseInt(possibleMoves.elementAt(z).toString()); System.out.println("SOURCE= "+source); dest=Integer.parseInt(possibleMoves.elementAt(z+1).toString());//(int[])possibleMoves.elementAt(z+1); System.out.println("DEST = "+dest); applyMove(newBoard,source,dest); newScore=MiniMax(newBoard,depth+1,opponent(turn),red_best, black_best); if(newScore>MAX_SCORE) {MAX_SCORE=newScore;maxSource=source; maxDest=dest;}//maxSource and maxDest will be used to perform the move. if (MAX_SCORE > black_best) { if (MAX_SCORE >= red_best) break; /* alpha_beta cutoff */ else black_best = (int) MAX_SCORE; //the_score } if (MAX_SCORE < red_best) { if (MAX_SCORE<= black_best) break; /* alpha_beta cutoff */ else red_best = (int) MAX_SCORE; //the_score } }//for ends return MAX_SCORE; } //end minimax I am unable to find out the logical mistake. Any idea what's going wrong?

    Read the article

  • How to utilize miniMax algorithm in Checkers game

    - by engineer
    I am sorry...as there are too many articles about it.But I can't simple get this. I am confused in the implementation of AI. I have generated all possible moves of computer's type pieces. Now I can't decide the flow. Whether I need to start a loop for the possible moves of each piece and assign score to it.... or something else is to be done. Kindly tell me the proper flow/algorithm for this. Thanks

    Read the article

  • How to utilize miniMax algorrithm in Checkers game

    - by engineer
    I am sorry...as there are too many articles about it.But I can't simple get this. I am confused in the implementation of AI. I have generated all possible moves of computer's type pieces. Now I can't decide the flow. Whether I need to start a loop for the possible moves of each piece and assign score to it.... or something else is to be done. Kindly tell me the proper flow/algorithm for this. Thanks

    Read the article

  • Static Evaluation Function for Checkers

    - by Kamikaze
    Hi all! I'm trying to write an evaluation function for a game of checkers that I'm developing but I can't find the right documentation. I've read several documents on the web witch describe different techniques for either writing one or letting the computer find it(using genetic algorithms or Bayesian learning) but they're too complicated for a novice like me. All documents pointed a reference to "Some studies in machine learning using the game of checkers" by A.L.Samuel but I couldn't get my hands on it yet :(. I've only read the follow up "Some studies in machine learning using the game of checkers -II" and found some good info there, but it doesn't explain what the eval parameters mean (I think I don't have the whole article). Thanks for your help!

    Read the article

  • Of what significance is the solution to the game of checkers in AI research?

    - by cobie
    I have been doing some research into artificial intelligence and I came across a 2007 paper titled "Checkers is Solved" on the game of checkers being solved by AI techniques after more than 16 years of trial. A solution to the game is defined by the team as "determining the final result in a game with no mistakes made by either player". The search for a solution started back in 1989 and it was finally found in 2007. Of what importance is this to the field of AI?

    Read the article

  • How to transfer url parameters to repoze custom predicate checkers

    - by user281521
    I would like to create a repoze custom predicate checker that is capable to access url parameters and validate something. But I would like to use allow_only to set this permission checker in all the controller's scope. Something like: class MyController(BaseController): allow_only = All(not_anonymous(msg=l_(u'You must be logged on')), my_custom_predicate(msg=l_(u'something wrong'))) def index(self, **kw): return dict() then, my_custom_predicate should check the url paramters for every request in every MyController method, and do whatever it do. The problem is just that: how to allow my_custom_predicate to check the url parameters, using it in that way I wrote above.

    Read the article

  • Online validators, syntax checkers, testing tools

    - by Max Gontar
    I often need to verify some simple code before posting, and it's great if I have installed IDE, but what if not? It would be nice to have online free tools for SQL, VB.NET, C# code validation, or maybe even testing. EDIT What I actually mean are online live web tools, like JSLint for javascript. Have you seen any?

    Read the article

  • X forwarding over SSH from Mac to a Linux box

    - by Checkers
    I need run Mac applications on a remote Mac machine and display it on a local Linux machine's X server (a lot of articles on the Internet seem to be detailing how would you do it the opposite way). $ ssh -X mac-box $ cd /Developer/Applications/Xcode.app $ ./Contents/MacOS/Xcode Sat Oct 3 20:41:26 mac-box.local Xcode[15634] <Error>: kCGErrorFailure: Set a breakpoint @ CGErrorBreakpoint() to catch errors as they are logged. _RegisterApplication(), FAILED TO establish the default connection to the WindowServer, _CGSDefaultConnection() is NULL. ^C My $DISPLAY variable appears to be empty. What should it look like so that forwarding works correctly? Can I run OSX applications this way at all?

    Read the article

  • What exactly does ssh send when performing key negotiation?

    - by Checkers
    When explicitly specifying identity file to ssh: ssh -i ./id_rsa ... I have these lines in ssh debug trace: debug1: Offering public key: ./id_rsa debug3: send_pubkey_test debug2: we sent a publickey packet, wait for reply Does it mean ssh-generated id_rsa contains public RSA exponent as well, or ssh is sending out my private key? (which, of course, does not make sense). id_rsa format seems to be rather explicit that it contains private key with its "BEGIN PRIVATE KEY" block.

    Read the article

  • "volatile" qualifier and compiler reorderings

    - by Checkers
    A compiler cannot eliminate or reorder reads/writes to a volatile-qualified variables. But what about the cases where other variables are present, which may or may not be volatile-qualified? Scenario 1 volatile int a; volatile int b; a = 1; b = 2; a = 3; b = 4; Can the compiler reorder first and the second, or third and the fourth assignments? Scenario 2 volatile int a; int b, c; b = 1; a = 1; c = b; a = 3; Same question, can the compiler reorder first and the second, or third and the fourth assignments?

    Read the article

  • Explain Python extensions multithreading

    - by Checkers
    Python interpreter has a Global Interpreter Lock, and it is my understanding that extensions must acquire it in a multi-threaded environment. But Boost.Python HOWTO page says the extension function must release the GIL and reacquire it on exit. I want to resist temptation to guess here, so I would like to know what should be GIL locking patterns in the following scenarios: Extension is called from python (presumably running in a python thread). And extension's background thread calls back into Py_* functions. And a final question is, why the linked document says the GIL should be released and re-acquired?

    Read the article

  • "call" instruction that seemingly jumps into itself

    - by Checkers
    I have gcc 4 compiling some C++ code into the following (from objdump): 00000030 <func()>: 30: 55 push %ebp 31: 89 e5 mov %esp,%ebp 33: 56 push %esi 34: 31 f6 xor %esi,%esi 36: 53 push %ebx 37: bb 00 00 00 00 mov $0x0,%ebx 3c: 83 ec 40 sub $0x40,%esp 3f: c7 04 24 01 00 00 00 movl $0x1,(%esp) 46: e8 fc ff ff ff call 47 <func()+0x17> 4b: 8d 55 ec lea 0xffffffec(%ebp),%edx 4e: 89 14 24 mov %edx,(%esp) 51: 89 5c 24 04 mov %ebx,0x4(%esp) 55: 89 74 24 08 mov %esi,0x8(%esp) 59: 89 44 24 0c mov %eax,0xc(%esp) ; the rest of the function is omitted I can't understand the operand of call instruction here, why does it call into itself, but with one byte off?

    Read the article

  • GCC emits extra code for boost::shared_ptr dereference

    - by Checkers
    I have the following code: #include <boost/shared_ptr.hpp> struct Foo { int a; }; static int A; void func_shared(const boost::shared_ptr<Foo> &foo) { A = foo->a; } void func_raw(Foo * const foo) { A = foo->a; } I thought the compiler would create identical code, but for shared_ptr version an extra seemingly redundant instruction is emitted. Disassembly of section .text: 00000000 <func_raw(Foo*)>: 0: 55 push ebp 1: 89 e5 mov ebp,esp 3: 8b 45 08 mov eax,DWORD PTR [ebp+8] 6: 5d pop ebp 7: 8b 00 mov eax,DWORD PTR [eax] 9: a3 00 00 00 00 mov ds:0x0,eax e: c3 ret f: 90 nop 00000010 <func_shared(boost::shared_ptr<Foo> const&)>: 10: 55 push ebp 11: 89 e5 mov ebp,esp 13: 8b 45 08 mov eax,DWORD PTR [ebp+8] 16: 5d pop ebp 17: 8b 00 mov eax,DWORD PTR [eax] 19: 8b 00 mov eax,DWORD PTR [eax] 1b: a3 00 00 00 00 mov ds:0x0,eax 20: c3 ret I'm just curious, is this necessary, or it is just an optimizer's shortcoming? Compiling with g++ 4.1.2, -O3 -NDEBUG.

    Read the article

  • Find max integer size that a floating point type can handle without loss of precision

    - by Checkers
    Double has range more than a 64-bit integer, but its precision is less dues to its representation (since double is 64-bit as well, it can't fit more actual values). So, when representing larger integers, you start to lose precision in the integer part. #include <boost/cstdint.hpp> #include <limits> template<typename T, typename TFloat> void maxint_to_double() { T i = std::numeric_limits<T>::max(); TFloat d = i; std::cout << std::fixed << i << std::endl << d << std::endl; } int main() { maxint_to_double<int, double>(); maxint_to_double<boost::intmax_t, double>(); maxint_to_double<int, float>(); return 0; } This prints: 2147483647 2147483647.000000 9223372036854775807 9223372036854775800.000000 2147483647 2147483648.000000 Note how max int can fit into a double without loss of precision and boost::intmax_t (64-bit in this case) cannot. float can't even hold an int. Now, the question: is there a way in C++ to check if the entire range of a given integer type can fit into a loating point type without loss of precision? Preferably, it would be a compile-time check that can be used in a static assertion, and would not involve enumerating the constants the compiler should know or can compute.

    Read the article

  • How to add a property to a module in boost::python?

    - by Checkers
    You can add a property to a class using a getter and a setter (in a simplistic case): class<X>("X") .add_property("foo", &X::get_foo, &X::set_foo); But how to add a property to a module itself (not a class)? There is scope().attr("globalAttr") = ??? something ??? and def("globalAttr", ??? something ???); I can add global functions and objects of my class using the above two ways, but can't seem to add properties the same way as in classes.

    Read the article

  • Iterator blocks in Clojure?

    - by Checkers
    I am using clojure.contrib.sql to fetch some records from an SQLite database. (defn read-all-foo [] (with-connection *db* (with-query-results res ["select * from foo"] (into [] res)))) Now, I don't really want to realize the whole sequence before returning from the function (i.e. I want to keep it lazy), but if I return res directly or wrap it some kind of lazy wrapper (for example I want to make a certain map transformation on result sequence), SQL-related bindings will be reset and connection will be closed after I return, so realizing the sequence will throw an exception. How can I enclose the whole function in a closure and return a kind of iterator block (like yield in C# or Python)? Or is there another way to return a lazy sequence from this function?

    Read the article

  • When binding a client TCP socket to a specific local port with Winsock, SO_REUSEADDR does not have a

    - by Checkers
    I'm binding a client TCP socket to a specific local port. To handle the situation where the socket remains in TIME_WAIT state for some time, I use setsockopt() with SO_REUSEADDR on a socket. It works on Linux, but does not work on Windows, I get WSAEADDRINUSE on connect() call when the previous connection is still in TIME_WAIT. MSDN is not exactly clear what should happen with client sockets: [...] For server applications that need to bind multiple sockets to the same port number, consider using setsockopt (SO_REUSEADDR). Client applications usually need not call bind at all—connect chooses an unused port automatically. [...] How do I avoid this?

    Read the article

  • Sample the deltas between values using boost::accumulators

    - by Checkers
    I have a data set with N integers (say, 13, 16, 17, 20) where each next sample is incremented by some value (3, 1, 3 in this case) and I want to use boost::accumulators::accumulator_set to find various statistics of the second sequence. I want to be able to do something like this: accumulator_set< double, features< tag::mean > > acc; ... acc(13); acc(16); acc(17); acc(20); ...BUT sampling the differences instead of the actual values. How can I do that with accumulator_set without keeping track of the last value manually?

    Read the article

1 2 3 4  | Next Page >