Need help with tic tac toe

Reply

Join Date: Oct 2009
Posts: 1
Reputation: c_crash is an unknown quantity at this point 
Solved Threads: 0
c_crash c_crash is offline Offline
Newbie Poster

Need help with tic tac toe

 
0
  #1
Oct 9th, 2009
hi

I'm trying to write a game where I play against the computer...and as u see below..I really suck at it..
can someone pleeease help me..I want it to be as simple as possible..

thanks

input random
game = raw_input("Your turn. Input the coordinate for your move on the form x,y: ")

for turn in range(9):
def print_board(board):
board = board.replace("_"," ")
print "." + "---." * 3
for bound in [0,3,6]:
print "|",
for sym in board[bound:bound+3]:
print sym, "|",
if bound < 6:
print "\n|" + "---|" * 3
print "\n'" + "---'" * 3

Empty = ' '
Player_X = 'x'
Computer_O = 'o'

a = 0,0
b = 0,1
c = 0,2
d = 1,0
e = 1,1
f = 1,2
g = 2,0
h = 2,1
i = 2,2
winlist = [(a,b,c), (d,e,f), (g,h,i), (a,d,g,), (b,e,h), (c,f,i), (a,e,i), (g,e,c)]

opponent = { Player_X : Computer_O, Computer_O : Player_X }

if winner == player:
print: ("I win!")
if winner == computer:
print: ("You win!")
if winner == none:
print: ("None")

board ()
raw_input ( 'Remi' )
Last edited by c_crash; Oct 9th, 2009 at 12:36 pm.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 1,046
Reputation: jlm699 is a jewel in the rough jlm699 is a jewel in the rough jlm699 is a jewel in the rough jlm699 is a jewel in the rough 
Solved Threads: 264
Sponsor
jlm699's Avatar
jlm699 jlm699 is offline Offline
Knows where his Towel is
 
1
  #2
Oct 9th, 2009
1) This program has no indentation. To preserve formatting on this forum you must wrap your code in [code=python]#Code tags[/code]. However after looking closer at your post it appears that your code has no indentation even in its original form.

2) You need to learn the difference between defining a function and calling one. You should never ever ever ever ever be defining a function inside a loop or any other regular code unless it truly needs to be a dynamic function (which you'll likely never encounter).
1. Use Code Tags.
2. Homework? Show Effort.
3. Keep discussions on the forum: no PMs
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC