Dear all,<br><br>I've written a class State that subclasses tuple. The class has a method move_state that takes a move and returns a new state object representing the new state of the game.<br><br>I would expect S1 and S3 to be equal on the last line here, but they are not.<br>
<br>>>> import game<br>>>> S = game.State()<br>>>> S1 = S.move_state(1).move_state("SWAP")<br>>>> S2 = S.move_state(1)<br>>>> S3 = S2.move_state("SWAP")<br>
>>> S1 == S3<br>False<br><br>Printing the two states shows that they have very different internal states.<br><br>>>> print S1<br> (8, 8, 8, 8, 8, 8, 0)<br>1 0<br> (7, 7, 7, 7, 7, 7, 7)<br>
>>> print S3<br> (7, 7, 7, 7, 7, 7, 7)<br>0 1<br> (0, 8, 8, 8, 8, 8, 8)<br><br>If anyone is interested, State represents the state of a 7 7 Kalah board.<br><br>The full code is on pastebin <a href="http://pastebin.com/tUh0W5Se">http://pastebin.com/tUh0W5Se</a><br>
<br>Are my expectations faulty? (I hope not)<br>Have I made some mistake in my code to get these results?<br><br>Thanks in advance,<br>Colin Caine<br><br>