# Help with game like checkers

**URL:** <https://forum.kirupa.com/t/help-with-game-like-checkers/274002>\
**Category:** Uncategorized\
**Created:** [October 23, 2008, 4:12pm UTC](https://forum.kirupa.com/t/help-with-game-like-checkers/274002 "2008-10-23T16:12:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![shedokan](https://avatars.discourse-cdn.com/v4/letter/s/977dab/32.png) [@shedokan](https://forum.kirupa.com/u/shedokan)\
**Post date:** [October 23, 2008, 4:12pm UTC](https://forum.kirupa.com/t/help-with-game-like-checkers/274002/1 "2008-10-23T16:12:48Z")

</div>

I am trying to do something like the jump over enemies in checkers.  
here’s a piece of code to check if a player tries to jump two tiles forward and if there’s another player or an enemy between, and if it has a stick in that direction:

```auto

[LEFT]if (y-cursorY == 2 && cursorX-x == 0 && players['p'+player]['c'+char].sticks['n'] && board[cursorY+1][cursorX][2]) {
    success = true;
}[/LEFT]
 

```

cursorY is the y direction here I try to go.  
cursorX is the x direction here I try to go.  
x is my current x direction.  
y is my current y direction.

players is the array where I store all my players, so players[‘p1’][‘c2’] will be player one and character 2.  
the sticks array is where I store all sticks of this character in 8 directions, so ‘n’ is north.

how can I make it jump over two or more characters?  
I mean I need something like path finding which will find the path to jump over other characters.  
I tried this:  
Code:

```auto
   
[LEFT]function make_path(ob) {
    game.path = [];
    while (ob.parentx != null) {
        game.path[game.path.length] = ob.x;
        game.path[game.path.length] = ob.y;
        ob = path["node_"+ob.parenty+"_"+ob.parentx];
    }
}
function findPath(startx, starty, targetx, targety, player, char) {
    path = {};
    path.Unchecked_Neighbours = [];
    path.done = false;
    path.name = "node_"+starty+"_"+startx;
    path[path.name] = {x:startx, y:starty, visited:true, parentx:null, parenty:null};
    path.Unchecked_Neighbours[path.Unchecked_Neighbours.length] = path[path.name];
    while (path.Unchecked_Neighbours.length>0) {
        var N = path.Unchecked_Neighbours.shift();
        if (N.x == targetx and N.y == targety) {
            //make_path(N);
            path.done = true;
            break;
        } else {
            N.visited = true;
            if (players['p'+player]['c'+char].sticks['e'] && x+1<=5) {
                addNode(N, N.x+1, N.y);
            }
            if (players['p'+player]['c'+char].sticks['w'] && x-1>=0) {
                addNode(N, N.x-1, N.y);
            }
            if (players['p'+player]['c'+char].sticks['s'] && y+1<=6) {
                addNode(N, N.x, N.y+1);
            }
            if (players['p'+player]['c'+char].sticks['n'] && y-1>=0) {
                addNode(N, N.x, N.y-1);
            }
        }
    }
    if (path.done) {
        delete path;
        return true;
        trace("success");
    } else {
        delete path;
        return false;
    }
}

[/LEFT]
  

```

I call it like this:

```auto
    
[LEFT]success = findPath(x, y, cursorX, cursorY, player, char);
if (success) {
    //execute code
}

[/LEFT]
  

```

but it stucks and asks me to abort the script.  
if you need more info ask me, I just don’t know how to do it.  
thanks.
