Skip to content

Milestone projects#6

Open
jaipurandare wants to merge 7 commits intomasterfrom
Milestone_Projects
Open

Milestone projects#6
jaipurandare wants to merge 7 commits intomasterfrom
Milestone_Projects

Conversation

@jaipurandare
Copy link
Collaborator

Created pull request so I can put comments

Copy link
Collaborator Author

@jaipurandare jaipurandare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have put my review comments. I don't know if you want to make all these changes.

" check_position=True\n",
" while check_position:\n",
" try:\n",
" if player_flag==True:\n",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

player_flag is a boolean. Not need to compare it to True or False. condition "if payer_flag:" is enough.

" global player1\n",
" global player2\n",
" check_player_input=True\n",
" while check_player_input: \n",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a note: This while loop can easily become infinite loop if the user keep entering wrong input. There should be limited number of attempts.

" length=9\n",
" winner_found=False\n",
" result=''\n",
" while length>0:\n",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can change the while condition as "length>0 and not winner_found". In that case no need to do length=0 after winner is found.

" print('Unable to understand the input. Please re-enter.')\n",
"\n",
"#Save the result of the game in a file\n",
"def result_file(result):\n",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should name the method based on action they perform. Like "save_result" or "save_result_to_file" or "write_to_file". Its more readable and makes sense about what the function is doing.

" while play_again_input: \n",
" replay=input('Would you like to play again? (Yes/No): ')\n",
" if replay=='Yes':\n",
" global board\n",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All these can be pulled out into a function called "reset_game" or "reset_board".

" player_select()\n",
" board_update()\n",
"\n",
"play_game_start()"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would write this as follows

def replay_game():
attempts = 0
play_again_invalid_input = True
while play_again_invalid_input and attempts < 3:
replay = input('Would you like to play again? (Yes/No): ')
if replay in ['Yes', 'No']:
play_again_invalid_input = False
else:
print('invalid input. re-enter')
attempts +=1
return replay == 'Yes'

yes = 'Yes'
no = 'No'
replay = True
while replay:
reset_game()
play_game_start()
replay = replay_game()

print('Game stopped as per you request!')

" print(result)\n",
" \n",
" result_file(result) \n",
" play_again()\n",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

play_again() should not be called here. It is not responsibility of the board_update function. It can be called at the end of play_game_start function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants