File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -27,6 +27,8 @@ Minor new features:
2727
2828* Allow `chess.Board.set_piece_at(square, None) `.
2929
30+ * Added `chess.SquareSet.from_square(square) `.
31+
3032New in v0.13.0
3133--------------
3234
Original file line number Diff line number Diff line change @@ -4097,3 +4097,13 @@ def __str__(self):
40974097
40984098 def __hash__ (self ):
40994099 return hash (self .mask )
4100+
4101+ @classmethod
4102+ def from_square (cls , square ):
4103+ """
4104+ Creates a SquareSet from a single square.
4105+
4106+ >>> chess.SquareSet.from_square(chess.A1) == chess.BB_A1:
4107+ True
4108+ """
4109+ return cls (BB_SQUARES [square ])
Original file line number Diff line number Diff line change @@ -1253,6 +1253,10 @@ def test_mutable_set_operations(self):
12531253 self .assertEqual (squares .pop (), chess .C7 )
12541254 self .assertEqual (squares , chess .BB_VOID )
12551255
1256+ def test_from_square (self ):
1257+ self .assertEqual (chess .SquareSet .from_square (chess .H5 ), chess .BB_H5 )
1258+ self .assertEqual (chess .SquareSet .from_square (chess .C2 ), chess .BB_C2 )
1259+
12561260
12571261class PolyglotTestCase (unittest .TestCase ):
12581262
You can’t perform that action at this time.
0 commit comments