Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimisations for history, pgn and getComments #421

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

gavin-lb
Copy link
Contributor

Improved the efficiency of several methods by including the pretty move in _history. Therefore, the entire game does not need to be replayed whenever the history needs to be iterated just to get the fen/san moves in each position.

Added an optional { pushPretty: false } flag to _makeMove . When provided, the pretty move will not be pushed to the history. This is so that when _makeMove is called only to be immediately followed by an _undoMove (which is a common design pattern throughout the library), the pretty move is not generated unnecessarily (and indeed potentially causing infinite recursion). However, this flag should only be used when the move is not intended to be left on the history.

Improved the efficiency of several methods by including the pretty move in _history. Therefore, the entire game does not need to be replayed whenever the history needs to be iterated just to get the fen/san moves in each position.

Added an optional { pushPretty: false } flag to _makeMove to adjust its behaviour. When provided, the pretty move will not be pushed to the history. This is so that when _makeMove is called only to be immediately followed by an _undoMove (which is a common design pattern throughout the library), the pretty move is not generated unnecessarily (and indeed potentially causing infinite recursion). However, this flag should only be used when the move is not intended to be left on the history.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant