Click here to Skip to main content
15,896,606 members
Home / Discussions / Algorithms
   

Algorithms

 
SuggestionVector representation of the code. Pin
Member 1406583326-Nov-18 7:50
Member 1406583326-Nov-18 7:50 
GeneralRe: Vector representation of the code. Pin
Gerry Schmitz27-Nov-18 9:19
mveGerry Schmitz27-Nov-18 9:19 
GeneralRe: Vector representation of the code. Pin
shooky561-Dec-18 5:04
shooky561-Dec-18 5:04 
QuestionOptimal Task Scheduling with Complete Knowledge Pin
Member 140435574-Nov-18 12:11
Member 140435574-Nov-18 12:11 
AnswerRe: Optimal Task Scheduling with Complete Knowledge Pin
Mycroft Holmes4-Nov-18 19:31
professionalMycroft Holmes4-Nov-18 19:31 
GeneralRe: Optimal Task Scheduling with Complete Knowledge Pin
Member 140435575-Nov-18 1:37
Member 140435575-Nov-18 1:37 
AnswerRe: Optimal Task Scheduling with Complete Knowledge Pin
Gerry Schmitz12-Nov-18 8:20
mveGerry Schmitz12-Nov-18 8:20 
QuestionChess Futility pruning Pin
GM Fafkorn5-Oct-18 22:13
GM Fafkorn5-Oct-18 22:13 
I'm creating a chess engine and I've tried to implement futility pruning. Results are sometimes worse than without it. Could somebody tell me what I'm doing wrong? My margin is set on 601 (pawn is set 200, knight/bishop 600 for example) Thanks

Same position
without futility on depth 5
Score: 90
Nodes: 89383
Depth: 5
Time: 2011ms

with futility on depth 5
Score: 90
Nodes: 85808
Depth: 5
Time: 1867ms

without futility on depth 6
Score: -16
Nodes: 836935
Depth: 6
Time: 12360ms

with futility on depth 6
Score: 65
Nodes: 855792
Depth: 6
Time: 12544ms


Java
<pre>private int negamax(Position node, int depth, int alpha, int beta, int color, byte castling) {
        if(depth == 0) {
            return quiescenceSearch(node, alpha, beta, color);
        }
        //
        //futility pruning
        //
        if(depth == 1) {
            int staticEval = color * countScore(node.pieces, depth, node.prevI, node.i);
            if(staticEval + margin < alpha) {
                return staticEval;
            }
        }
        //
        //generating moves
        //
        ArrayList<Move> possibleMoves = generateMove(node.pieces, node.prevI, node.i, getMoveByColor(color), castling);

        if(possibleMoves.size() == 0) {
            return color * countScore(node.pieces, depth, node.prevI, node.i);
        }

        orderMoves(possibleMoves, node.pieces);

        int value = MIN;
        for (Move possibleMove : possibleMoves) {
            Piece tempPiece = node.pieces[possibleMove.getI()];
            int prevPiece = node.pieces[possibleMove.getPrevI()].getType();
            node.pieces[possibleMove.getPrevI()].move(possibleMove.getI(), possibleMove.getPrevI(), node.pieces, 0);
            byte tempCastling = setCastling(node.prevI, node.i, castling);
            Move temp = new Move(node.i, node.prevI);
            node.prevI = possibleMove.getPrevI();
            node.i = possibleMove.getI();

            int tempValue;
            tempValue = -negamax(node, depth - 1, -beta, -alpha, -color, tempCastling);

            value = Math.max(value, tempValue);
            undo(possibleMove.getI(), possibleMove.getPrevI(), node.pieces, tempPiece, prevPiece);
            node.prevI = temp.getPrevI();
            node.i = temp.getI();
            alpha = Math.max(alpha, value);
            if (depth == searchDepth) {
                if (value > bestMoveValue) {
                    bestMoveValue = value;
                    bestMove = new Move(possibleMove.getI(), possibleMove.getPrevI());
                }
            }
        }
        return value;
    }

QuestionAlgorithms help Pin
Member 139775798-Sep-18 7:36
Member 139775798-Sep-18 7:36 
QuestionStart with a group of size X, divide it into Y groups, Z times, minimize overlap Pin
Member 139396526-Aug-18 5:08
Member 139396526-Aug-18 5:08 
AnswerRe: Start with a group of size X, divide it into Y groups, Z times, minimize overlap Pin
Stefan_Lang7-Aug-18 23:29
Stefan_Lang7-Aug-18 23:29 
AnswerRe: Start with a group of size X, divide it into Y groups, Z times, minimize overlap Pin
Gerry Schmitz8-Aug-18 8:38
mveGerry Schmitz8-Aug-18 8:38 
GeneralRe: Start with a group of size X, divide it into Y groups, Z times, minimize overlap Pin
Stefan_Lang8-Aug-18 21:12
Stefan_Lang8-Aug-18 21:12 
GeneralRe: Start with a group of size X, divide it into Y groups, Z times, minimize overlap Pin
Gerry Schmitz9-Aug-18 9:52
mveGerry Schmitz9-Aug-18 9:52 
GeneralRe: Start with a group of size X, divide it into Y groups, Z times, minimize overlap Pin
Stefan_Lang9-Aug-18 21:42
Stefan_Lang9-Aug-18 21:42 
GeneralRe: Start with a group of size X, divide it into Y groups, Z times, minimize overlap Pin
Kenneth Haugland9-Aug-18 22:25
mvaKenneth Haugland9-Aug-18 22:25 
GeneralRe: Start with a group of size X, divide it into Y groups, Z times, minimize overlap Pin
Gerry Schmitz11-Aug-18 9:19
mveGerry Schmitz11-Aug-18 9:19 
GeneralRe: Start with a group of size X, divide it into Y groups, Z times, minimize overlap Pin
Gerry Schmitz10-Aug-18 7:38
mveGerry Schmitz10-Aug-18 7:38 
GeneralRe: Start with a group of size X, divide it into Y groups, Z times, minimize overlap Pin
Stefan_Lang27-Aug-18 0:25
Stefan_Lang27-Aug-18 0:25 
AnswerRe: Start with a group of size X, divide it into Y groups, Z times, minimize overlap Pin
Patrice T1-Sep-18 16:42
mvePatrice T1-Sep-18 16:42 
QuestionSimplex Downhill... Pin
User 110609793-Aug-18 9:35
User 110609793-Aug-18 9:35 
AnswerRe: Simplex Downhill... Pin
Stefan_Lang5-Aug-18 21:33
Stefan_Lang5-Aug-18 21:33 
GeneralRe: Simplex Downhill... Pin
User 110609796-Aug-18 4:47
User 110609796-Aug-18 4:47 
GeneralRe: Simplex Downhill... Pin
Stefan_Lang7-Aug-18 2:21
Stefan_Lang7-Aug-18 2:21 
GeneralRe: Simplex Downhill... Pin
User 110609797-Aug-18 21:23
User 110609797-Aug-18 21:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.