On 4/27/2016 7:00 PM, Michael Torrie wrote:
I am guessing that the reason you are storing state as it's own dictionary is so that you can pass the state itself to the constructor?

Someone said it was bad to store the object itself to file (my original plan) and that I should use a dictionary instead. This is my implementation of that idea. However, saving and loading data is far down my to do list.

I know you've stated reasons for doing things the way you have, but this self._state dict smells a bit funny, especially where you have self._state = state, which means that several instances could have the exact same state object at the same time and strikes me as mildly un-pythonic and very confusing. "State" is what instances themselves are supposed to track by design. I recommend you use this feature rather than duplicating it with your own error-prone dict handling.

So far the code is working as designed for new chess pieces (see below).

Thank you,

Chris R.

Rook('white', (1, 1)) @ 2106251742008
Knight('white', (1, 2)) @ 2106251755648
Bishop('white', (1, 3)) @ 2106251755760
Queen('white', (1, 4)) @ 2106251755872
King('white', (1, 5)) @ 2106251755984
Bishop('white', (1, 6)) @ 2106251756096
Knight('white', (1, 7)) @ 2106251756208
Rook('white', (1, 8)) @ 2106251756320
Pawn('white', (2, 1)) @ 2106251756432
Pawn('white', (2, 2)) @ 2106251756544
Pawn('white', (2, 3)) @ 2106251756656
Pawn('white', (2, 4)) @ 2106251756768
Pawn('white', (2, 5)) @ 2106251756880
Pawn('white', (2, 6)) @ 2106251756992
Pawn('white', (2, 7)) @ 2106251757104
Pawn('white', (2, 8)) @ 2106251757216
Pawn('black', (7, 1)) @ 2106251742288
Pawn('black', (7, 2)) @ 2106251742400
Pawn('black', (7, 3)) @ 2106251742512
Pawn('black', (7, 4)) @ 2106251742624
Pawn('black', (7, 5)) @ 2106251742736
Pawn('black', (7, 6)) @ 2106251742848
Pawn('black', (7, 7)) @ 2106251742960
Pawn('black', (7, 8)) @ 2106251743072
Rook('black', (8, 1)) @ 2106251743184
Knight('black', (8, 2)) @ 2106251742120
Bishop('black', (8, 3)) @ 2106251740608
Queen('black', (8, 4)) @ 2106251740496
King('black', (8, 5)) @ 2106251740832
Bishop('black', (8, 6)) @ 2106251741672
Knight('black', (8, 7)) @ 2106251741784
Rook('black', (8, 8)) @ 2106251741896

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to