Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 2 of 2 FirstFirst 12
Results 16 to 20 of 20
  1. #16
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,218
    Thanks
    12
    Thanked 338 Times in 334 Posts
    well ... I left it on my work PC, so you’ll have to wait til I’m back there.
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer

  2. Users who have thanked Dormilich for this post:

    futbolinis (12-17-2012)

  3. #17
    New to the CF scene
    Join Date
    Dec 2012
    Location
    Vilnius, Lithuania
    Posts
    7
    Thanks
    3
    Thanked 0 Times in 0 Posts
    I will

  4. #18
    Regular Coder
    Join Date
    May 2012
    Location
    France
    Posts
    224
    Thanks
    0
    Thanked 32 Times in 30 Posts
    There is a new under construction game... It should also test blocked players (*) and especially to use AI to play against the script !

    Good luck!

    EDIT: (*) This is done !
    Last edited by 007julien; 12-18-2012 at 07:10 PM.

  5. #19
    New to the CF scene
    Join Date
    Dec 2012
    Location
    Vilnius, Lithuania
    Posts
    7
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Thank you for this example, but i'm still waiting for a Dormilich solution

  6. #20
    Regular Coder
    Join Date
    May 2012
    Location
    France
    Posts
    224
    Thanks
    0
    Thanked 32 Times in 30 Posts
    Don't use arrays to represent the board ... Binaries are the language for computer.

    The pieces of a player (Noughts or Crosses) can be listed with a unique binary !

    This binary is 0 at the beginning and increased of 1<<c (one bit left shifted of c), if the player choose the cell c (from 0 to 8). See the source of the proposal game.

    Then the win positions are represented only with an array of 8 integers,
    Code:
    var winPos=[7,56,448,73,146,292,273,84];
    The first one is (1<<0) + (1<<1) + (1<<2) = 1 + 2 + 4, the second is the first shifted of 3 or multiplied by 8 ... etc.

    The tests are very simple with bitwise operators : a position p win if there is an i for which p&winPos[i]==winPos[i] !

    NB : For other non trivial games see the Gomoku and the list of the solved games
    Last edited by 007julien; 12-23-2012 at 02:13 AM.


 
Page 2 of 2 FirstFirst 12

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •