Jump to content
  • Advertisement
Sign in to follow this  
steveworks

TicTacToe conditional help

This topic is 3747 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

oh no i double posted again!!!! I am a begginning python programmer and I need some help with a TicTacToe program I am trying to write. My biggest issue is my innability to make a specific winner. I cannot for the life of me make a way to check if either player wins that works. Right now I only have a broken function that is supposed to check if player 1 'X' wins. here is my code. I couldn't figure out how to make it go into a seperate piece that scrolls down like other people. b = ['_','_','_','_','_','_','_','_','_'] w = 1 check = 0 def printboard(): print '[',b[0],'][',b[1],'][',b[2],']' ' [ 1 ][ 2 ][ 3 ]' print '[',b[3],'][',b[4],'][',b[5],']' ' [ 4 ][ 5 ][ 6 ]' print '[',b[6],'][',b[7],'][',b[8],']' ' [ 7 ][ 8 ][ 9 ]' def plr1(): s = int(raw_input('player 1 make your move')) b[s - 1] = 'X' def plr2(): s = int(raw_input('player 2 make your move')) b[s - 1] = 'O' def winner1(): check = b[0] + b[1] + b[2] checking1() check = b[3] + b[4] + b[5] checking1() check = b[6] + b[7] + b[8] checking1() check = b[0] + b[3] + b[6] checking1() check = b[1] + b[4] + b[7] checking1() check = b[2] + b[5] + b[8] checking1() check = b[0] + b[4] + b[8] checking1() check = b[6] + b[4] + b[2] checking1() def checking1(): if check == 'XXX': print 'player 1 is the winner' w = 2 while True: printboard() plr1() winner1() if w = = 2: break printboard() plr2() if w = = 2: break If someone can point me to a place that gives ideas on ways that I can make an efficient working conditional please post. Any help on making this work is highly appreciated. If anyone needs anymore information I'll gladly post it. [Edited by - steveworks on June 17, 2008 8:11:46 PM]

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!