douglasbagnall / p4wn

a smallish turn-of-the-century javascript chess engine
http://p4wn.sf.net
113 stars 33 forks source link

who to move #20

Closed questsin closed 7 years ago

questsin commented 8 years ago

trying to use chess.js and p4wn. but p4wn doesnt move black from a fen. It moves white. Is this an error? how do I tell p4wn to move black or that next move, black's move?

//loading fen.. back to move var state = p4_fen2state(game.fen());
_ref = p4wn.findmove(2), from = _ref[0], to = _ref[1]; //, score = _ref[3] ; ai_move = p4wn.move(from, to); //p4wn moves white.

douglasbagnall commented 8 years ago

As written your code won't work, because you aren't using the state variable you create, instead pulling p4wn out from somewhere and addressing that.