Skip to content

Commit

Permalink
accept duplicate nodes in PGN
Browse files Browse the repository at this point in the history
  • Loading branch information
fohristiwhirl committed Jun 16, 2019
1 parent 2ecd70e commit 394e8ef
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion 6_pgn.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ function LoadPGNRecord(o) {
throw `"${s}" -- ${error}`;
}

node = node.make_move(move);
node = node.make_move(move, true);
}
}

Expand Down
10 changes: 6 additions & 4 deletions 8_tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@

const node_prototype = {

make_move: function(s) {
make_move: function(s, force_new_node) {

// s must be exactly a legal move, including having promotion char iff needed (e.g. e2e1q)

for (let child of this.children) {
if (child.move === s) {
return child;
if (!force_new_node) {
for (let child of this.children) {
if (child.move === s) {
return child;
}
}
}

Expand Down

0 comments on commit 394e8ef

Please sign in to comment.