Dick Moores wrote:
> 1. Is wrapping the long lines where I have done so OK?

I usually indent the second line of a wrapped line so it stands out more.

> 2. I've used 1 for White player, -1 for Black player, and (-1)*player
> to alternate players. Is there a better way?
> 3. I've used a lot of variables. Too Many?

I think it might work well to either put the player variables into lists 
or simple classes.

> 4. Should more of the code be in functions?

That might make it read more easily. Alternately some blank lines to 
break the code into sections would aid readability.

> 5. Is there a way to collapse lines 130-137?:
> if player == 1: # player is White
>                  whiteMoveCounter += 1
>                  print "Black to make move %d" % (blackMoveCounter)
>                  remainingWhiteTime -= timeUsedThisMove
> elif player == -1: # player is Black
>                  blackMoveCounter += 1
>                  print "White to make move %d" % (whiteMoveCounter)
>                  remainingBlackTime -= timeUsedThisMove

If the players were objects then this might look like

currentPlayer.moveCounter += 1
otherPlayer.printNextMove()
currentPlayer.remainingTime -= timeUsedThisMove

Switching players would be done with
currentPlayer, otherPlayer = otherPlayer, currentPlayer

Kent
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to