Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Page 1 of 2 12 LastLast
Results 1 to 25 of 27

Thread: This is a link to full executable jar file.

  1. #1
    Junior Member
    Join Date
    Jun 2012
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default This is a link to full executable jar file.

    Link: MobileChess-TouchScreen(1).jar

    In evaluate class,what is represented by distance?


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,327
    Thanks
    181
    Thanked 828 Times in 771 Posts
    Blog Entries
    5

    Default Re: This is a link to full executable jar file.

    Thread moved to Java Theory & Questions

    I honestly don't even know what you are asking...and I can only speak for myself, but am not going to download an executable jar from an unknown source

  3. #3
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,327
    Thanks
    181
    Thanked 828 Times in 771 Posts
    Blog Entries
    5

    Default Re: This is a link to full executable jar file.


  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    20,942
    Thanks
    51
    Thanked 2,267 Times in 2,239 Posts

    Default Re: This is a link to full executable jar file.

    Post the code here that you have questions about.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Jun 2012
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: This is a link to full executable jar file.


  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    20,942
    Thanks
    51
    Thanked 2,267 Times in 2,239 Posts

    Default Re: This is a link to full executable jar file.

    Copy and paste here the code you have questions about. Be sure to wrap the code with[code=java]<YOUR CODE HERE>[/code] to get highlighting
    If you don't understand my answer, don't ignore it, ask a question.

  7. #7
    Junior Member
    Join Date
    Jun 2012
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: This is a link to full executable jar file.

    part of code (full code on link):


    package chess;
     
     
    // Referenced classes of package chess:
    //            Position, Util
     
    public class Evaluate
    {
     
        public static final int PIECE_KING = 0;
        public static final int PIECE_QUEEN = 1;
        public static final int PIECE_ROOK = 2;
        public static final int PIECE_BISHOP = 3;
        public static final int PIECE_KNIGHT = 4;
        public static final int PIECE_PAWN = 5;
        public static final int FULL_BIT_RANK = 4080;
        public static final int LAZY_MARGIN = 100;
        public static final int ISOLATED_PENALTY = 10;
        public static final int DOUBLE_PENALTY = 4;
        public static final int PIECE_VALUE[] = {
            0, 9, 5, 3, 3, 1
        };
        public static final int PASS_PAWN[] = {
            0, 35, 30, 20, 10, 5, 0, 0
        };
        public static final byte DISTANCE[] = {
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            0, 7, 6, 7, 0, 0, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 7, 6, 5, 6, 
            7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            0, 7, 6, 5, 4, 5, 6, 7, 0, 0, 
            0, 0, 0, 0, 0, 0, 7, 6, 5, 4, 
            3, 4, 5, 6, 7, 0, 0, 0, 0, 0, 
            0, 7, 6, 5, 4, 3, 2, 3, 4, 5, 
            6, 7, 0, 0, 0, 0, 7, 6, 5, 4, 
            3, 2, 1, 2, 3, 4, 5, 6, 7, 0, 
            0, 7, 6, 5, 4, 3, 2, 1, 0, 1, 
            2, 3, 4, 5, 6, 7, 0, 0, 7, 6, 
            5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 
            7, 0, 0, 0, 0, 7, 6, 5, 4, 3, 
            2, 3, 4, 5, 6, 7, 0, 0, 0, 0, 
            0, 0, 7, 6, 5, 4, 3, 4, 5, 6, 
            7, 0, 0, 0, 0, 0, 0, 0, 0, 7, 
            6, 5, 4, 5, 6, 7, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 7, 6, 5, 6, 
            7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            0, 0, 0, 7, 6, 7, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0
        };
    Last edited by rajeshverma; June 15th, 2012 at 11:21 AM.

  8. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    20,942
    Thanks
    51
    Thanked 2,267 Times in 2,239 Posts

    Default Re: This is a link to full executable jar file.

    What is you question about the code?

    Please Edit your post and wrap your code with[code=java]<YOUR CODE HERE>[/code] to get highlighting
    If you don't understand my answer, don't ignore it, ask a question.

  9. #9
    Junior Member
    Join Date
    Jun 2012
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: This is a link to full executable jar file.

    Question is : what is represented by 'distance' in code ?

  10. #10
    Junior Member
    Join Date
    Jun 2012
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: This is a link to full executable jar file.

    This code is a part of mobile chess jar file downloaded from : Mobile Chess and Flash Chess | Free Games software downloads at SourceForge.net

  11. #11
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    20,942
    Thanks
    51
    Thanked 2,267 Times in 2,239 Posts

    Default Re: This is a link to full executable jar file.

    It looks like an array of byte values. How does the code use the contents of the array? You will have to read the code and see how it is used. Perhaps the author's comments will explain what it is used for.
    How many elements are there in the array? Does that number correspond with any other features of the program?
    If you don't understand my answer, don't ignore it, ask a question.

  12. #12
    Junior Member
    Join Date
    Jun 2012
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: This is a link to full executable jar file.

    Yes sir,it is an array of byte values. Second thing, I don't know author. Now as far as correspondence with any other features is concerned, I guess it has something to do with chessboard.

    Other detail: (1)I have downloaded this from : Mobile Chess and Flash Chess | Free Games software downloads at SourceForge.net .
    (2)I have decompiled the jar.
    (3)Now I post full code under.
    (4)The code is for 'evaluating' position on board.
    (5)Other things about code ,I feel, it uses alpha-beta for analysis,squares have different values in all functions
    package chess;
     
     
    // Referenced classes of package chess:
    //            Position, Util
     
    public class Evaluate
    {
     
        public static final int PIECE_KING = 0;
        public static final int PIECE_QUEEN = 1;
        public static final int PIECE_ROOK = 2;
        public static final int PIECE_BISHOP = 3;
        public static final int PIECE_KNIGHT = 4;
        public static final int PIECE_PAWN = 5;
        public static final int FULL_BIT_RANK = 4080;
        public static final int LAZY_MARGIN = 100;
        public static final int ISOLATED_PENALTY = 10;
        public static final int DOUBLE_PENALTY = 4;
        public static final int PIECE_VALUE[] = {
            0, 9, 5, 3, 3, 1
        };
        public static final int PASS_PAWN[] = {
            0, 35, 30, 20, 10, 5, 0, 0
        };
        public static final byte DISTANCE[] = {
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            0, 7, 6, 7, 0, 0, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 7, 6, 5, 6, 
            7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            0, 7, 6, 5, 4, 5, 6, 7, 0, 0, 
            0, 0, 0, 0, 0, 0, 7, 6, 5, 4, 
            3, 4, 5, 6, 7, 0, 0, 0, 0, 0, 
            0, 7, 6, 5, 4, 3, 2, 3, 4, 5, 
            6, 7, 0, 0, 0, 0, 7, 6, 5, 4, 
            3, 2, 1, 2, 3, 4, 5, 6, 7, 0, 
            0, 7, 6, 5, 4, 3, 2, 1, 0, 1, 
            2, 3, 4, 5, 6, 7, 0, 0, 7, 6, 
            5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 
            7, 0, 0, 0, 0, 7, 6, 5, 4, 3, 
            2, 3, 4, 5, 6, 7, 0, 0, 0, 0, 
            0, 0, 7, 6, 5, 4, 3, 4, 5, 6, 
            7, 0, 0, 0, 0, 0, 0, 0, 0, 7, 
            6, 5, 4, 5, 6, 7, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 7, 6, 5, 6, 
            7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            0, 0, 0, 7, 6, 7, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0
        };
        public static final byte ENDGAME_EDGE[] = {
            0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 
            1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 
            1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 
            0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 
            0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 
            0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 
            0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 
            0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 
            0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 
            0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 
            1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 
            0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 
            1, 1, 1, 1, 0, 0, 0, 0
        };
        public static final byte ENDGAME_BOTTOM[] = {
            0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 
            1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 
            1, 1, 1, 1, 0, 0, 0, 0
        };
        public static final byte ENDGAME_KING_PENALTY[] = {
            0, 0, 0, 0, 25, 22, 19, 16, 16, 19, 
            22, 25, 0, 0, 0, 0, 0, 0, 0, 0, 
            17, 14, 11, 8, 8, 11, 14, 17, 0, 0, 
            0, 0, 0, 0, 0, 0, 13, 10, 7, 4, 
            4, 7, 10, 13, 0, 0, 0, 0, 0, 0, 
            0, 0, 9, 6, 3, 0, 0, 3, 6, 9, 
            0, 0, 0, 0, 0, 0, 0, 0, 9, 6, 
            3, 0, 0, 3, 6, 9, 0, 0, 0, 0, 
            0, 0, 0, 0, 13, 10, 7, 4, 4, 7, 
            10, 13, 0, 0, 0, 0, 0, 0, 0, 0, 
            17, 14, 11, 8, 8, 11, 14, 17, 0, 0, 
            0, 0, 0, 0, 0, 0, 25, 22, 19, 16, 
            16, 19, 22, 25, 0, 0, 0, 0
        };
        public static final byte EDGE_PENALTY[] = {
            0, 0, 0, 0, 6, 5, 4, 3, 3, 4, 
            5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 
            5, 4, 3, 2, 2, 3, 4, 5, 0, 0, 
            0, 0, 0, 0, 0, 0, 4, 3, 2, 1, 
            1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 
            0, 0, 3, 2, 1, 0, 0, 1, 2, 3, 
            0, 0, 0, 0, 0, 0, 0, 0, 3, 2, 
            1, 0, 0, 1, 2, 3, 0, 0, 0, 0, 
            0, 0, 0, 0, 4, 3, 2, 1, 1, 2, 
            3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 
            5, 4, 3, 2, 2, 3, 4, 5, 0, 0, 
            0, 0, 0, 0, 0, 0, 6, 5, 4, 3, 
            3, 4, 5, 6, 0, 0, 0, 0
        };
        public static final byte PAWN_VALUE[] = {
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            30, 30, 46, 70, 78, 46, 30, 30, 0, 0, 
            0, 0, 0, 0, 0, 0, 8, 8, 22, 43, 
            50, 22, 8, 8, 0, 0, 0, 0, 0, 0, 
            0, 0, 4, 4, 16, 34, 40, 16, 4, 4, 
            0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 
            12, 27, 32, 12, 2, 2, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 8, 20, 24, 8, 
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            0, 0, 6, 15, 18, 6, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 0, 0
        };
        public static final byte CENTER_IMPORTANCE[] = {
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 0, 0, 2, 5, 
            5, 2, 0, 0, 0, 0, 0, 0, 0, 0, 
            0, 0, 0, 2, 5, 8, 8, 5, 2, 0, 
            0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 
            5, 8, 8, 5, 2, 0, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 2, 5, 5, 2, 
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 0, 0
        };
        public static final byte RANK_IMPORTANCE[] = {
            0, 0, 0, 0, 12, 12, 12, 12, 12, 12, 
            12, 12, 0, 0, 0, 0, 0, 0, 0, 0, 
            12, 12, 12, 12, 12, 12, 12, 12, 0, 0, 
            0, 0, 0, 0, 0, 0, 6, 6, 6, 6, 
            6, 6, 6, 6, 0, 0, 0, 0, 0, 0, 
            0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 0, 0
        };
     
        public Evaluate()
        {
        }
     
        public static boolean IN_BOARD(int sq)
        {
            return Position.IN_BOARD(sq);
        }
     
        public static int SQUARE_FLIP(int sq)
        {
            return Position.SQUARE_FLIP(sq);
        }
     
        public static int losingKingValue(int sq)
        {
            return -ENDGAME_KING_PENALTY[sq] * 2 - ENDGAME_BOTTOM[sq] * 8;
        }
     
        public static int winningKingValue(int sq, int sqOppKing)
        {
            return -DISTANCE[(sqOppKing - sq) + 128] * 2 - ENDGAME_EDGE[sq] * 8;
        }
     
        public static int calcRookControl(Position pos, int sqSrc, short attack[])
        {
            return calcSlideControl(pos, sqSrc, attack, true);
        }
     
        public static int calcBishopControl(Position pos, int sqSrc, short attack[])
        {
            return calcSlideControl(pos, sqSrc, attack, false);
        }
     
        public static int calcSlideControl(Position pos, int sqSrc, short attack[], boolean isRook)
        {
            int control = 0;
            for(int i = 0; i < 4; i++)
            {
                int delta = isRook ? Position.ROOK_DELTA[i] : Position.BISHOP_DELTA[i];
                int sqDst = sqSrc + delta;
                boolean direct = true;
                for(; IN_BOARD(sqDst); sqDst += delta)
                {
                    control += direct ? ((int) (attack[sqDst])) : attack[sqDst] / 2;
                    if(pos.squares[sqDst] <= 0)
                    {
                        continue;
                    }
                    int pieceType = Position.PIECE_TYPE(pos.squares[sqDst]);
                    if(pieceType == 5)
                    {
                        break;
                    }
                    if(pieceType == 0 || pieceType == 4 || pieceType == (isRook ? 3 : 2))
                    {
                        direct = false;
                    }
                }
     
            }
     
            return control;
        }
     
        public static void preEval(Position pos)
        {
            int vlWhite = 0;
            int vlBlack = 0;
            int sqWhiteKing = 0;
            int sqBlackKing = 0;
            for(int sq = 0; sq < 128; sq++)
            {
                int pc = pos.squares[sq];
                if(pc != 0)
                {
                    if(pc < 16)
                    {
                        vlWhite += PIECE_VALUE[pc - 8];
                        if(pc == 8)
                        {
                            sqWhiteKing = sq;
                        }
                    } else
                    {
                        vlBlack += PIECE_VALUE[pc - 16];
                        if(pc == 16)
                        {
                            sqBlackKing = sq;
                        }
                    }
                }
            }
     
            boolean inEndgame = Math.min(vlWhite, vlBlack) <= 6 && Math.abs(vlWhite - vlBlack) >= 2;
            short whiteAttack[] = new short[128];
            short blackAttack[] = new short[128];
            for(int sq = 0; sq < 128; sq++)
            {
                whiteAttack[sq] = blackAttack[SQUARE_FLIP(sq)] = (short)((RANK_IMPORTANCE[sq] * Math.max((vlWhite + vlBlack) - 24, 8)) / 32 + CENTER_IMPORTANCE[sq]);
            }
     
            for(int i = 0; i < 8; i++)
            {
                int importance = (12 * Math.max((vlWhite + vlBlack) - 24, 8)) / 32;
                int sq = sqWhiteKing + Position.KING_DELTA[i];
                if(IN_BOARD(sq))
                {
                    blackAttack[sq] += importance;
                }
                sq = sqBlackKing + Position.KING_DELTA[i];
                if(IN_BOARD(sq))
                {
                    whiteAttack[sq] += importance;
                }
            }
     
            short whiteRookControl[] = new short[128];
            short whiteBishopControl[] = new short[128];
            short blackRookControl[] = new short[128];
            short blackBishopControl[] = new short[128];
            for(int sq = 0; sq < 128; sq++)
            {
                if(IN_BOARD(sq))
                {
                    whiteRookControl[sq] = (short)calcRookControl(pos, sq, whiteAttack);
                    blackRookControl[sq] = (short)calcRookControl(pos, sq, blackAttack);
                    whiteBishopControl[sq] = (short)calcBishopControl(pos, sq, whiteAttack);
                    blackBishopControl[sq] = (short)calcBishopControl(pos, sq, blackAttack);
                }
            }
     
            for(int sq = 0; sq < 128; sq++)
            {
                if(IN_BOARD(sq))
                {
                    int edgePenalty = EDGE_PENALTY[sq];
                    if(inEndgame)
                    {
                        if(vlWhite < vlBlack)
                        {
                            pos.vlWhitePiecePos[0][sq] = (short)losingKingValue(sq);
                            pos.vlBlackPiecePos[0][sq] = (short)winningKingValue(sq, sqWhiteKing);
                        } else
                        {
                            pos.vlBlackPiecePos[0][sq] = (short)losingKingValue(sq);
                            pos.vlWhitePiecePos[0][sq] = (short)winningKingValue(sq, sqBlackKing);
                        }
                        for(int i = 1; i <= 4; i++)
                        {
                            pos.vlWhitePiecePos[i][sq] = pos.vlBlackPiecePos[i][sq] = (short)(PIECE_VALUE[i] * 100);
                        }
     
                    } else
                    {
                        if(vlWhite + vlBlack <= 32)
                        {
                            pos.vlWhitePiecePos[0][sq] = pos.vlBlackPiecePos[0][sq] = (short)(-edgePenalty);
                        } else
                        {
                            pos.vlWhitePiecePos[0][sq] = pos.vlBlackPiecePos[0][sq] = 0;
                        }
                        pos.vlWhitePiecePos[1][sq] = (short)(PIECE_VALUE[1] * 100 + (whiteRookControl[sq] + whiteBishopControl[sq]) / 8);
                        pos.vlBlackPiecePos[1][sq] = (short)(PIECE_VALUE[1] * 100 + (blackRookControl[sq] + blackBishopControl[sq]) / 8);
                        pos.vlWhitePiecePos[2][sq] = (short)(PIECE_VALUE[2] * 100 + whiteRookControl[sq] / 2);
                        pos.vlBlackPiecePos[2][sq] = (short)(PIECE_VALUE[2] * 100 + blackRookControl[sq] / 2);
                        pos.vlWhitePiecePos[3][sq] = (short)(PIECE_VALUE[3] * 100 + whiteBishopControl[sq] / 2);
                        pos.vlBlackPiecePos[3][sq] = (short)(PIECE_VALUE[3] * 100 + blackBishopControl[sq] / 2);
                        int whiteKnightAttack = 0;
                        int blackKnightAttack = 0;
                        for(int i = 0; i < 8; i++)
                        {
                            int sqDst = sq + Position.KNIGHT_DELTA[i];
                            if(IN_BOARD(sqDst))
                            {
                                whiteKnightAttack += whiteAttack[sqDst];
                                blackKnightAttack += blackAttack[sqDst];
                            }
                        }
     
                        pos.vlWhitePiecePos[4][sq] = (short)((PIECE_VALUE[4] * 100 + whiteKnightAttack / 4) - (edgePenalty * 3) / 2);
                        pos.vlBlackPiecePos[4][sq] = (short)((PIECE_VALUE[4] * 100 + blackKnightAttack / 4) - (edgePenalty * 3) / 2);
                    }
                    pos.vlWhitePiecePos[5][sq] = pos.vlBlackPiecePos[5][SQUARE_FLIP(sq)] = (short)((PIECE_VALUE[5] * 100 + PAWN_VALUE[sq] / 2) - 6);
                }
            }
     
            for(int sd = 0; sd < 2; sd++)
            {
                int brSelf = 0;
                int brSide = 0;
                int brBehindOppPass = 0;
                int brOppPass = 4080;
                for(int i = 1; i <= 6; i++)
                {
                    int y = sd != 0 ? i : 7 - i;
                    int brOpp = sd != 0 ? pos.brWhitePawn[y] : pos.brBlackPawn[y];
                    brOppPass &= ~(brSelf | brSide);
                    brBehindOppPass |= brOppPass & brOpp;
                    int brChain = brSide;
                    brSelf = sd != 0 ? pos.brBlackPawn[y] : pos.brWhitePawn[y];
                    brSide = (brSelf >> 1 | brSelf << 1) & 0xff0;
                    int brForward = sd != 0 ? pos.brBlackPawn[y + 1] : pos.brWhitePawn[y + 1];
                    int brLeftCover = brForward >> 1 & 0xff0;
                    int brRightCover = brForward << 1 & 0xff0;
                    for(int x = 4; x <= 11; x++)
                    {
                        int sq = Position.COORD_XY(x, y);
                        int brSquare = 1 << x;
                        int value = ((brSide & brSquare) == 0 ? 0 : 3) + ((brChain & brSquare) == 0 ? 0 : 2);
                        value += ((brLeftCover & brSquare) == 0 ? 0 : 2) + ((brRightCover & brSquare) == 0 ? 0 : 2);
                        value += (brSelf & brSquare) == 0 ? 0 : 1;
                        if(sd == 0)
                        {
                            pos.vlWhitePiecePos[5][sq] += value;
                        } else
                        {
                            pos.vlBlackPiecePos[5][sq] += value;
                        }
                        if(vlWhite + vlBlack <= 32)
                        {
                            if((brOppPass & brSquare) != 0)
                            {
                                if(sd == 0)
                                {
                                    pos.vlBlackPiecePos[5][sq] += PASS_PAWN[i];
                                } else
                                {
                                    pos.vlWhitePiecePos[5][sq] += PASS_PAWN[i];
                                }
                            }
                            if((brBehindOppPass & brSquare) != 0)
                            {
                                pos.vlWhitePiecePos[2][sq] += 8;
                                pos.vlBlackPiecePos[2][sq] += 8;
                                if(i == 6)
                                {
                                    int sqBottom = sq + Position.FORWARD_DELTA(sd);
                                    pos.vlWhitePiecePos[2][sqBottom] += 8;
                                    pos.vlBlackPiecePos[2][sqBottom] += 8;
                                }
                            }
                        }
                    }
     
                }
     
            }
     
            for(int sq = 103; sq <= 104; sq++)
            {
                if(pos.squares[sq] == 13)
                {
                    pos.vlWhitePiecePos[3][sq - 16] -= 10;
                }
            }
     
            for(int sq = 23; sq <= 24; sq++)
            {
                if(pos.squares[sq] == 21)
                {
                    pos.vlBlackPiecePos[3][sq + 16] -= 10;
                }
            }
     
            pos.vlWhite = pos.vlBlack = 0;
            for(int sq = 0; sq < 128; sq++)
            {
                int pc = pos.squares[sq];
                if(pc > 0)
                {
                    if(pc < 16)
                    {
                        pos.vlWhite += pos.vlWhitePiecePos[pc - 8][sq];
                    } else
                    {
                        pos.vlBlack += pos.vlBlackPiecePos[pc - 16][sq];
                    }
                }
            }
     
        }
     
        public static int evaluate(Position pos, int vlAlpha, int vlBeta)
        {
            int vl = pos.material();
            if(vl + 100 <= vlAlpha)
            {
                return vl + 100;
            }
            if(vl - 100 >= vlBeta)
            {
                return vl - 100;
            }
            for(int sd = 0; sd < 2; sd++)
            {
                int brSingle = 0;
                int brDouble = 0;
                int brs[] = sd != 0 ? pos.brBlackPawn : pos.brWhitePawn;
                for(int i = 1; i <= 6; i++)
                {
                    brDouble |= brSingle & brs[i];
                    brSingle |= brs[i];
                }
     
                int brIsolated = brSingle & ~(brSingle << 1 | brSingle >> 1);
                int penalty = Util.POP_COUNT_16(brDouble) * 4 + Util.POP_COUNT_16(brIsolated) * 10 + Util.POP_COUNT_16(brIsolated & brDouble) * 10 * 2;
                vl += pos.sdPlayer != sd ? penalty : -penalty;
            }
     
            return vl;
        }
     
    }

  13. #13
    Junior Member
    Join Date
    Jun 2012
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: This is a link to full executable jar file.

    Yes sir,it is an array of byte values. Second thing, I don't know author. Now as far as correspondence with any other features is concerned, I guess it has something to do with chessboard.

    Other detail: (1)I have downloaded this from : Mobile Chess and Flash Chess | Free Games software downloads at SourceForge.net .
    (2)I have decompiled the jar.
    (3)Now I post full code under.
    (4)The code is for 'evaluating' position on board.
    (5)Other things about code ,I feel, it uses alpha-beta for analysis,squares have different values in all functions
    package chess;
     
     
    // Referenced classes of package chess:
    //            Position, Util
     
    public class Evaluate
    {
     
        public static final int PIECE_KING = 0;
        public static final int PIECE_QUEEN = 1;
        public static final int PIECE_ROOK = 2;
        public static final int PIECE_BISHOP = 3;
        public static final int PIECE_KNIGHT = 4;
        public static final int PIECE_PAWN = 5;
        public static final int FULL_BIT_RANK = 4080;
        public static final int LAZY_MARGIN = 100;
        public static final int ISOLATED_PENALTY = 10;
        public static final int DOUBLE_PENALTY = 4;
        public static final int PIECE_VALUE[] = {
            0, 9, 5, 3, 3, 1
        };
        public static final int PASS_PAWN[] = {
            0, 35, 30, 20, 10, 5, 0, 0
        };
        public static final byte DISTANCE[] = {
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            0, 7, 6, 7, 0, 0, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 7, 6, 5, 6, 
            7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            0, 7, 6, 5, 4, 5, 6, 7, 0, 0, 
            0, 0, 0, 0, 0, 0, 7, 6, 5, 4, 
            3, 4, 5, 6, 7, 0, 0, 0, 0, 0, 
            0, 7, 6, 5, 4, 3, 2, 3, 4, 5, 
            6, 7, 0, 0, 0, 0, 7, 6, 5, 4, 
            3, 2, 1, 2, 3, 4, 5, 6, 7, 0, 
            0, 7, 6, 5, 4, 3, 2, 1, 0, 1, 
            2, 3, 4, 5, 6, 7, 0, 0, 7, 6, 
            5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 
            7, 0, 0, 0, 0, 7, 6, 5, 4, 3, 
            2, 3, 4, 5, 6, 7, 0, 0, 0, 0, 
            0, 0, 7, 6, 5, 4, 3, 4, 5, 6, 
            7, 0, 0, 0, 0, 0, 0, 0, 0, 7, 
            6, 5, 4, 5, 6, 7, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 7, 6, 5, 6, 
            7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            0, 0, 0, 7, 6, 7, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0
        };
        public static final byte ENDGAME_EDGE[] = {
            0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 
            1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 
            1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 
            0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 
            0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 
            0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 
            0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 
            0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 
            0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 
            0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 
            1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 
            0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 
            1, 1, 1, 1, 0, 0, 0, 0
        };
        public static final byte ENDGAME_BOTTOM[] = {
            0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 
            1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 
            1, 1, 1, 1, 0, 0, 0, 0
        };
        public static final byte ENDGAME_KING_PENALTY[] = {
            0, 0, 0, 0, 25, 22, 19, 16, 16, 19, 
            22, 25, 0, 0, 0, 0, 0, 0, 0, 0, 
            17, 14, 11, 8, 8, 11, 14, 17, 0, 0, 
            0, 0, 0, 0, 0, 0, 13, 10, 7, 4, 
            4, 7, 10, 13, 0, 0, 0, 0, 0, 0, 
            0, 0, 9, 6, 3, 0, 0, 3, 6, 9, 
            0, 0, 0, 0, 0, 0, 0, 0, 9, 6, 
            3, 0, 0, 3, 6, 9, 0, 0, 0, 0, 
            0, 0, 0, 0, 13, 10, 7, 4, 4, 7, 
            10, 13, 0, 0, 0, 0, 0, 0, 0, 0, 
            17, 14, 11, 8, 8, 11, 14, 17, 0, 0, 
            0, 0, 0, 0, 0, 0, 25, 22, 19, 16, 
            16, 19, 22, 25, 0, 0, 0, 0
        };
        public static final byte EDGE_PENALTY[] = {
            0, 0, 0, 0, 6, 5, 4, 3, 3, 4, 
            5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 
            5, 4, 3, 2, 2, 3, 4, 5, 0, 0, 
            0, 0, 0, 0, 0, 0, 4, 3, 2, 1, 
            1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 
            0, 0, 3, 2, 1, 0, 0, 1, 2, 3, 
            0, 0, 0, 0, 0, 0, 0, 0, 3, 2, 
            1, 0, 0, 1, 2, 3, 0, 0, 0, 0, 
            0, 0, 0, 0, 4, 3, 2, 1, 1, 2, 
            3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 
            5, 4, 3, 2, 2, 3, 4, 5, 0, 0, 
            0, 0, 0, 0, 0, 0, 6, 5, 4, 3, 
            3, 4, 5, 6, 0, 0, 0, 0
        };
        public static final byte PAWN_VALUE[] = {
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            30, 30, 46, 70, 78, 46, 30, 30, 0, 0, 
            0, 0, 0, 0, 0, 0, 8, 8, 22, 43, 
            50, 22, 8, 8, 0, 0, 0, 0, 0, 0, 
            0, 0, 4, 4, 16, 34, 40, 16, 4, 4, 
            0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 
            12, 27, 32, 12, 2, 2, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 8, 20, 24, 8, 
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            0, 0, 6, 15, 18, 6, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 0, 0
        };
        public static final byte CENTER_IMPORTANCE[] = {
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 0, 0, 2, 5, 
            5, 2, 0, 0, 0, 0, 0, 0, 0, 0, 
            0, 0, 0, 2, 5, 8, 8, 5, 2, 0, 
            0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 
            5, 8, 8, 5, 2, 0, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 2, 5, 5, 2, 
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 0, 0
        };
        public static final byte RANK_IMPORTANCE[] = {
            0, 0, 0, 0, 12, 12, 12, 12, 12, 12, 
            12, 12, 0, 0, 0, 0, 0, 0, 0, 0, 
            12, 12, 12, 12, 12, 12, 12, 12, 0, 0, 
            0, 0, 0, 0, 0, 0, 6, 6, 6, 6, 
            6, 6, 6, 6, 0, 0, 0, 0, 0, 0, 
            0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 0, 0
        };
     
        public Evaluate()
        {
        }
     
        public static boolean IN_BOARD(int sq)
        {
            return Position.IN_BOARD(sq);
        }
     
        public static int SQUARE_FLIP(int sq)
        {
            return Position.SQUARE_FLIP(sq);
        }
     
        public static int losingKingValue(int sq)
        {
            return -ENDGAME_KING_PENALTY[sq] * 2 - ENDGAME_BOTTOM[sq] * 8;
        }
     
        public static int winningKingValue(int sq, int sqOppKing)
        {
            return -DISTANCE[(sqOppKing - sq) + 128] * 2 - ENDGAME_EDGE[sq] * 8;
        }
     
        public static int calcRookControl(Position pos, int sqSrc, short attack[])
        {
            return calcSlideControl(pos, sqSrc, attack, true);
        }
     
        public static int calcBishopControl(Position pos, int sqSrc, short attack[])
        {
            return calcSlideControl(pos, sqSrc, attack, false);
        }
     
        public static int calcSlideControl(Position pos, int sqSrc, short attack[], boolean isRook)
        {
            int control = 0;
            for(int i = 0; i < 4; i++)
            {
                int delta = isRook ? Position.ROOK_DELTA[i] : Position.BISHOP_DELTA[i];
                int sqDst = sqSrc + delta;
                boolean direct = true;
                for(; IN_BOARD(sqDst); sqDst += delta)
                {
                    control += direct ? ((int) (attack[sqDst])) : attack[sqDst] / 2;
                    if(pos.squares[sqDst] <= 0)
                    {
                        continue;
                    }
                    int pieceType = Position.PIECE_TYPE(pos.squares[sqDst]);
                    if(pieceType == 5)
                    {
                        break;
                    }
                    if(pieceType == 0 || pieceType == 4 || pieceType == (isRook ? 3 : 2))
                    {
                        direct = false;
                    }
                }
     
            }
     
            return control;
        }
     
        public static void preEval(Position pos)
        {
            int vlWhite = 0;
            int vlBlack = 0;
            int sqWhiteKing = 0;
            int sqBlackKing = 0;
            for(int sq = 0; sq < 128; sq++)
            {
                int pc = pos.squares[sq];
                if(pc != 0)
                {
                    if(pc < 16)
                    {
                        vlWhite += PIECE_VALUE[pc - 8];
                        if(pc == 8)
                        {
                            sqWhiteKing = sq;
                        }
                    } else
                    {
                        vlBlack += PIECE_VALUE[pc - 16];
                        if(pc == 16)
                        {
                            sqBlackKing = sq;
                        }
                    }
                }
            }
     
            boolean inEndgame = Math.min(vlWhite, vlBlack) <= 6 && Math.abs(vlWhite - vlBlack) >= 2;
            short whiteAttack[] = new short[128];
            short blackAttack[] = new short[128];
            for(int sq = 0; sq < 128; sq++)
            {
                whiteAttack[sq] = blackAttack[SQUARE_FLIP(sq)] = (short)((RANK_IMPORTANCE[sq] * Math.max((vlWhite + vlBlack) - 24, 8)) / 32 + CENTER_IMPORTANCE[sq]);
            }
     
            for(int i = 0; i < 8; i++)
            {
                int importance = (12 * Math.max((vlWhite + vlBlack) - 24, 8)) / 32;
                int sq = sqWhiteKing + Position.KING_DELTA[i];
                if(IN_BOARD(sq))
                {
                    blackAttack[sq] += importance;
                }
                sq = sqBlackKing + Position.KING_DELTA[i];
                if(IN_BOARD(sq))
                {
                    whiteAttack[sq] += importance;
                }
            }
     
            short whiteRookControl[] = new short[128];
            short whiteBishopControl[] = new short[128];
            short blackRookControl[] = new short[128];
            short blackBishopControl[] = new short[128];
            for(int sq = 0; sq < 128; sq++)
            {
                if(IN_BOARD(sq))
                {
                    whiteRookControl[sq] = (short)calcRookControl(pos, sq, whiteAttack);
                    blackRookControl[sq] = (short)calcRookControl(pos, sq, blackAttack);
                    whiteBishopControl[sq] = (short)calcBishopControl(pos, sq, whiteAttack);
                    blackBishopControl[sq] = (short)calcBishopControl(pos, sq, blackAttack);
                }
            }
     
            for(int sq = 0; sq < 128; sq++)
            {
                if(IN_BOARD(sq))
                {
                    int edgePenalty = EDGE_PENALTY[sq];
                    if(inEndgame)
                    {
                        if(vlWhite < vlBlack)
                        {
                            pos.vlWhitePiecePos[0][sq] = (short)losingKingValue(sq);
                            pos.vlBlackPiecePos[0][sq] = (short)winningKingValue(sq, sqWhiteKing);
                        } else
                        {
                            pos.vlBlackPiecePos[0][sq] = (short)losingKingValue(sq);
                            pos.vlWhitePiecePos[0][sq] = (short)winningKingValue(sq, sqBlackKing);
                        }
                        for(int i = 1; i <= 4; i++)
                        {
                            pos.vlWhitePiecePos[i][sq] = pos.vlBlackPiecePos[i][sq] = (short)(PIECE_VALUE[i] * 100);
                        }
     
                    } else
                    {
                        if(vlWhite + vlBlack <= 32)
                        {
                            pos.vlWhitePiecePos[0][sq] = pos.vlBlackPiecePos[0][sq] = (short)(-edgePenalty);
                        } else
                        {
                            pos.vlWhitePiecePos[0][sq] = pos.vlBlackPiecePos[0][sq] = 0;
                        }
                        pos.vlWhitePiecePos[1][sq] = (short)(PIECE_VALUE[1] * 100 + (whiteRookControl[sq] + whiteBishopControl[sq]) / 8);
                        pos.vlBlackPiecePos[1][sq] = (short)(PIECE_VALUE[1] * 100 + (blackRookControl[sq] + blackBishopControl[sq]) / 8);
                        pos.vlWhitePiecePos[2][sq] = (short)(PIECE_VALUE[2] * 100 + whiteRookControl[sq] / 2);
                        pos.vlBlackPiecePos[2][sq] = (short)(PIECE_VALUE[2] * 100 + blackRookControl[sq] / 2);
                        pos.vlWhitePiecePos[3][sq] = (short)(PIECE_VALUE[3] * 100 + whiteBishopControl[sq] / 2);
                        pos.vlBlackPiecePos[3][sq] = (short)(PIECE_VALUE[3] * 100 + blackBishopControl[sq] / 2);
                        int whiteKnightAttack = 0;
                        int blackKnightAttack = 0;
                        for(int i = 0; i < 8; i++)
                        {
                            int sqDst = sq + Position.KNIGHT_DELTA[i];
                            if(IN_BOARD(sqDst))
                            {
                                whiteKnightAttack += whiteAttack[sqDst];
                                blackKnightAttack += blackAttack[sqDst];
                            }
                        }
     
                        pos.vlWhitePiecePos[4][sq] = (short)((PIECE_VALUE[4] * 100 + whiteKnightAttack / 4) - (edgePenalty * 3) / 2);
                        pos.vlBlackPiecePos[4][sq] = (short)((PIECE_VALUE[4] * 100 + blackKnightAttack / 4) - (edgePenalty * 3) / 2);
                    }
                    pos.vlWhitePiecePos[5][sq] = pos.vlBlackPiecePos[5][SQUARE_FLIP(sq)] = (short)((PIECE_VALUE[5] * 100 + PAWN_VALUE[sq] / 2) - 6);
                }
            }
     
            for(int sd = 0; sd < 2; sd++)
            {
                int brSelf = 0;
                int brSide = 0;
                int brBehindOppPass = 0;
                int brOppPass = 4080;
                for(int i = 1; i <= 6; i++)
                {
                    int y = sd != 0 ? i : 7 - i;
                    int brOpp = sd != 0 ? pos.brWhitePawn[y] : pos.brBlackPawn[y];
                    brOppPass &= ~(brSelf | brSide);
                    brBehindOppPass |= brOppPass & brOpp;
                    int brChain = brSide;
                    brSelf = sd != 0 ? pos.brBlackPawn[y] : pos.brWhitePawn[y];
                    brSide = (brSelf >> 1 | brSelf << 1) & 0xff0;
                    int brForward = sd != 0 ? pos.brBlackPawn[y + 1] : pos.brWhitePawn[y + 1];
                    int brLeftCover = brForward >> 1 & 0xff0;
                    int brRightCover = brForward << 1 & 0xff0;
                    for(int x = 4; x <= 11; x++)
                    {
                        int sq = Position.COORD_XY(x, y);
                        int brSquare = 1 << x;
                        int value = ((brSide & brSquare) == 0 ? 0 : 3) + ((brChain & brSquare) == 0 ? 0 : 2);
                        value += ((brLeftCover & brSquare) == 0 ? 0 : 2) + ((brRightCover & brSquare) == 0 ? 0 : 2);
                        value += (brSelf & brSquare) == 0 ? 0 : 1;
                        if(sd == 0)
                        {
                            pos.vlWhitePiecePos[5][sq] += value;
                        } else
                        {
                            pos.vlBlackPiecePos[5][sq] += value;
                        }
                        if(vlWhite + vlBlack <= 32)
                        {
                            if((brOppPass & brSquare) != 0)
                            {
                                if(sd == 0)
                                {
                                    pos.vlBlackPiecePos[5][sq] += PASS_PAWN[i];
                                } else
                                {
                                    pos.vlWhitePiecePos[5][sq] += PASS_PAWN[i];
                                }
                            }
                            if((brBehindOppPass & brSquare) != 0)
                            {
                                pos.vlWhitePiecePos[2][sq] += 8;
                                pos.vlBlackPiecePos[2][sq] += 8;
                                if(i == 6)
                                {
                                    int sqBottom = sq + Position.FORWARD_DELTA(sd);
                                    pos.vlWhitePiecePos[2][sqBottom] += 8;
                                    pos.vlBlackPiecePos[2][sqBottom] += 8;
                                }
                            }
                        }
                    }
     
                }
     
            }
     
            for(int sq = 103; sq <= 104; sq++)
            {
                if(pos.squares[sq] == 13)
                {
                    pos.vlWhitePiecePos[3][sq - 16] -= 10;
                }
            }
     
            for(int sq = 23; sq <= 24; sq++)
            {
                if(pos.squares[sq] == 21)
                {
                    pos.vlBlackPiecePos[3][sq + 16] -= 10;
                }
            }
     
            pos.vlWhite = pos.vlBlack = 0;
            for(int sq = 0; sq < 128; sq++)
            {
                int pc = pos.squares[sq];
                if(pc > 0)
                {
                    if(pc < 16)
                    {
                        pos.vlWhite += pos.vlWhitePiecePos[pc - 8][sq];
                    } else
                    {
                        pos.vlBlack += pos.vlBlackPiecePos[pc - 16][sq];
                    }
                }
            }
     
        }
     
        public static int evaluate(Position pos, int vlAlpha, int vlBeta)
        {
            int vl = pos.material();
            if(vl + 100 <= vlAlpha)
            {
                return vl + 100;
            }
            if(vl - 100 >= vlBeta)
            {
                return vl - 100;
            }
            for(int sd = 0; sd < 2; sd++)
            {
                int brSingle = 0;
                int brDouble = 0;
                int brs[] = sd != 0 ? pos.brBlackPawn : pos.brWhitePawn;
                for(int i = 1; i <= 6; i++)
                {
                    brDouble |= brSingle & brs[i];
                    brSingle |= brs[i];
                }
     
                int brIsolated = brSingle & ~(brSingle << 1 | brSingle >> 1);
                int penalty = Util.POP_COUNT_16(brDouble) * 4 + Util.POP_COUNT_16(brIsolated) * 10 + Util.POP_COUNT_16(brIsolated & brDouble) * 10 * 2;
                vl += pos.sdPlayer != sd ? penalty : -penalty;
            }
     
            return vl;
        }
     
    }

  14. #14
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    20,942
    Thanks
    51
    Thanked 2,267 Times in 2,239 Posts

    Default Re: This is a link to full executable jar file.

    I have decompiled the jar.
    If you do not have the original source with the author's comments, you will have to spend lots of time trying to figure out what the code does and why it is doing what it does.

    Good luck.
    If you don't understand my answer, don't ignore it, ask a question.

  15. #15
    Junior Member
    Join Date
    Jun 2012
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: This is a link to full executable jar file.

    how can i know if i don know what is distance refering ?

  16. #16
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    20,942
    Thanks
    51
    Thanked 2,267 Times in 2,239 Posts

    Default Re: This is a link to full executable jar file.

    Look at the source and see how it is used.
    If you don't understand my answer, don't ignore it, ask a question.

  17. #17
    Junior Member
    Join Date
    Jun 2012
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: This is a link to full executable jar file.

    Quote Originally Posted by Norm View Post
    Look at the source and see how it is used.
    I looked ,problem is 256 values how used for 64 squares of chessboard? in functions also only, int sq ,i.e. final value is used. if i remove it,no error in compiling but as a whole program no work ,why ?

  18. #18
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    20,942
    Thanks
    51
    Thanked 2,267 Times in 2,239 Posts

    Default Re: This is a link to full executable jar file.

    if i remove it, no error in compiling
    If the array is not used, you can remove it and there should not be any compiler errors and the execution of the program should not change.

    Its strange there are no compiler errors. There should be an error for the line in this method:
      public static int winningKingValue(int sq, int sqOppKing)
        {
            return -DISTANCE[(sqOppKing - sq) + 128] * 2 - ENDGAME_EDGE[sq] * 8;
        }
    If you don't understand my answer, don't ignore it, ask a question.

  19. #19
    Junior Member
    Join Date
    Jun 2012
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: This is a link to full executable jar file.

    Quote Originally Posted by Norm View Post
    If the array is not used, you can remove it and there should not be any compiler errors and the execution of the program should not change.

    Its strange there are no compiler errors. There should be an error for the line in this method:
      public static int winningKingValue(int sq, int sqOppKing)
        {
            return -DISTANCE[(sqOppKing - sq) + 128] * 2 - ENDGAME_EDGE[sq] * 8;
        }
    could be because the final byte value null??

  20. #20
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    20,942
    Thanks
    51
    Thanked 2,267 Times in 2,239 Posts

    Default Re: This is a link to full executable jar file.

    byte variables can not have a null value.
    If you don't understand my answer, don't ignore it, ask a question.

  21. #21
    Junior Member
    Join Date
    Jun 2012
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: This is a link to full executable jar file.

    I have found same code on googlecode :http://j2me-chess.googlecode.com/svn.../Evaluate.java

  22. #22
    Junior Member
    Join Date
    Jun 2012
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: This is a link to full executable jar file.

    (1)It explains function.
    (2)I was right for alpha beta.
    (3)it shows squares as byte values.
    (4)here also endgame edge and bottom make sense.
    (5)square of distance (byte values) not match as board.

  23. #23
    Junior Member
    Join Date
    Jun 2012
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: This is a link to full executable jar file.

    Quote Originally Posted by Norm View Post
    byte variables can not have a null value.
    yes , that is.

  24. #24
    Junior Member
    Join Date
    Jun 2012
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: This is a link to full executable jar file.

    can i get answer of this? if yes,how where?

  25. #25
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    20,942
    Thanks
    51
    Thanked 2,267 Times in 2,239 Posts

    Default Re: This is a link to full executable jar file.

    Ask the author
    If you don't understand my answer, don't ignore it, ask a question.

Page 1 of 2 12 LastLast

Similar Threads

  1. [SOLVED] no sound from executable jar file
    By cl2606 in forum What's Wrong With My Code?
    Replies: 17
    Last Post: June 8th, 2011, 06:41 PM
  2. Jar Executable File Not Working
    By Kimimaru in forum Java Theory & Questions
    Replies: 6
    Last Post: October 15th, 2010, 09:32 PM
  3. Jar Executable File
    By The_Mexican in forum What's Wrong With My Code?
    Replies: 43
    Last Post: June 23rd, 2010, 03:53 PM
  4. [SOLVED] Executable .jar file isnít launched after being double-clicked
    By voltaire in forum Java Theory & Questions
    Replies: 6
    Last Post: May 18th, 2010, 03:37 PM