Skip to content

Commit

Permalink
Setting position resets info (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhelyabuzhsky authored Mar 1, 2020
1 parent 37ed4e1 commit 85bc759
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2016-2019 Ilya Zhelyabuzhsky
Copyright (c) 2016-2020 Ilya Zhelyabuzhsky

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
name="stockfish",
author="Ilya Zhelyabuzhsky",
author_email="zhelyabuzhsky@icloud.com",
version="3.6.0",
version="3.7.0",
license="MIT",
keywords="chess stockfish",
python_requires=">=3.7",
Expand Down
3 changes: 2 additions & 1 deletion stockfish/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
This module implements the Stockfish class.
:copyright: (c) 2016-2019 by Ilya Zhelyabuzhsky.
:copyright: (c) 2016-2020 by Ilya Zhelyabuzhsky.
:license: MIT, see LICENSE for more details.
"""

Expand Down Expand Up @@ -97,6 +97,7 @@ def set_position(self, moves: List[str] = None) -> None:
Returns:
None
"""
self.__start_new_game()
if moves is None:
moves = []
self.__put(f"position startpos moves {self.__convert_move_list_to_str(moves)}")
Expand Down
7 changes: 7 additions & 0 deletions tests/stockfish/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ def test_get_best_move_first_move(self, stockfish):
best_move = stockfish.get_best_move()
assert best_move in ("e2e3", "e2e4", "g1f3", "b1c3")

def test_set_position_resets_info(self, stockfish):
stockfish.set_position(["e2e4", "e7e6"])
stockfish.get_best_move()
assert stockfish.info != ""
stockfish.set_position(["e2e4", "e7e6"])
assert stockfish.info == ""

def test_get_best_move_not_first_move(self, stockfish):
stockfish.set_position(["e2e4", "e7e6"])
best_move = stockfish.get_best_move()
Expand Down

0 comments on commit 85bc759

Please sign in to comment.