Python Forum
Game not letting player 1 win straight away
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Game not letting player 1 win straight away
#5
Nilamo's code is an outline of how your program might be run. The player1 and player2 comments show where you would get the moves from those players.

My code has to do with your checkX and checkY functions. They both are a long list of if statements. My first bit of code shows how you could simplify the conditions in those if statements. My second bit of code shows how you could make one loop to to test all the conditions. The lines list would be a list of the index triplets that make a line on the board. That is, the indexes from each of the if conditions in checkX/checkY. Then you can loop through the index triplets and use them to check each line, greatly simplifying your code. All else being equal, simpler code is better. It's easier to maintain, upgrade, and leads to less bugs.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
RE: Game not letting player 1 win straight away - by ichabod801 - Aug-15-2017, 09:56 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  trying to put a a filter on identifying a straight CompleteNewb 1 1,683 Dec-01-2021, 11:11 PM
Last Post: CompleteNewb
  coding a 2-player die game Pepper887 3 2,482 Mar-17-2019, 04:02 PM
Last Post: ichabod801

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020