Forum: Python hjälp

Forum huvudsida -> Programmering -> Python hjälp

Sidor: 1

Till botten

Sib911 19:33 - 9:e April 2010 | Post #1
Medlem
Inlägg: 1


Skicka PM
Hejsan

Jag är ny när det gäller programmering och nu har jag skrivit en kod i python som representerar spelet tic tac toe. Men den gör inte riktigt som jag vill. Jag vill att datorn ska försöka förhindra den andra från att vinna, och det ska dessutom kunna bli oavgjort och att det då printas ut "It's a tie" eller nåt liknande, men jag har inte lyckats. Finns det någon som skulle kunna hjälpa mig med koden? Jag har kämpst länge med det.
Tack



  1. import random
  2.  
  3. Board = ['1 ', '2', '3 ', '4', '5 ', '6', '7 ', '8', '9 ']
  4.  
  5. EMPTY = "_"
  6. X = "X"
  7. O = "O"
  8. TIE = "TIE"
  9. NUM_SQUARES = 9
  10. X = player
  11. computer = O
  12.  
  13. def Playboard ():
  14. XRange for rx in (0.3):
  15. rx = r * 3
  16. print '|% s |% s |% s |'% (board [r 0], board [r +1], board [r 2])
  17. print
  18.  
  19. def Win ():
  20. a, b, c, d, e, f, g, h, i = Board
  21. winlist = [(a, b, c), (d, e, f), (g, h, i), (a, d, g), (b, e, h), (c, f, and )
  22. (A, e, i), (g, e, c)]
  23. winning = False
  24. for the in winlist:
  25. f in [0] == in [1] == in [2]:
  26. winning = w [0]
  27.  
  28. winning return
  29.  
  30. playerwin = False
  31. Run = True
  32. while Run:
  33. Playboard ()
  34.  
  35. choice = True
  36. while choice:
  37. play = raw_input ("Make a move, 1-9")
  38. play.lower f () in ["quit", "exit", "close", "end"]:
  39. choice = Run = False
  40.  
  41. try:
  42. play = int (play)
  43. int f (Board [play-1]) == play:
  44. Board [play-1] = 'X'
  45. choice = False
  46. Except:
  47. pass
  48.  
  49. Win f ():
  50. playerwin = True
  51. Playboard ()
  52. print "You Win!"
  53. Run = False
  54.  
  55. f playerwin == False:
  56. Moves = []
  57. XRange for n in (0.9):
  58. if board [n] == str (n +1):
  59. Moves.append (str (n))
  60.  
  61. Random.randint X = (0, len (Moves) -1)
  62. X = Moves [X]
  63. Board [int (X)] = "O"
  64.  
  65. Win f ():
  66. #if all ([et al ['X', 'O'] for i in Board]):
  67. # Print "REMI"
  68. # Playerwin = True
  69. # Run = False
  70. Playboard ()
  71. print "Computer Win!"
  72. Run = False



Senast redigerad 21:58 - 10:e April 2010


bridgetlawrence 07:15 - 19:e September 2017 | Post #2
Medlem
Inlägg: 2


Skicka PM

Ball pythons needn't bother with a warm light of any kind, you can put a light finished the tank I utilize ordinary family unit lights for all the same snakes I have they help the temps marginally, however, are more for my enjoying. Best Essay Writing Service. The ball python needs an under the tank radiator put on one side of the tank so it can either go to the warm side or cool side so it can thermoregulate its temp.






alinakl 15:05 - 27:e September 2017 | Post #3
Medlem
Inlägg: 1


Skicka PM

According to Assignment Writers client profile gives a synopsis depicting a gathering of clients. Since the profile is intended to incorporate every one of the clients inside the gathering, the points of interest in the profile for the most part portray reaches or frequencies of reactions. This quantitative photo of a gathering of clients can be important for distinguishing plan and advancement needs, and is regularly a decent beginning stage for client investigation. In any case, the quantitative profile can have a few confinements. Midpoints and extents don't generally give a total or precise picture. For example, discovering that a gathering of 100 clients has a normal age of 35 may prompt unexpected choices in comparison to realizing that 50 clients were age 20 and 50 clients were age 50.






Lydiawade 13:36 - 10:e Oktober 2017 | Post #4
Medlem
Inlägg: 1


Skicka PM

These days every business needs its site to convey unmistakable and rich client encounter. Python designers search for alternatives to tweak bits of sites without putting any additional time and exertion. As an adaptable web structure, Django empowers them to tweak diverse bits of a site. Rather than utilizing Help With Assignment pre-manufactured web applications, the software engineers are required to concentrate just on modifying bits of the site as indicated by customer's particular prerequisites. The concentration empowers them to make applications that convey significant substance or data as indicated by the particular needs of client.




Senast redigerad 13:37 - 10:e Oktober 2017


quickessayhelp 08:36 - 18:e Oktober 2017 | Post #5
Medlem
Inlägg: 1


Skicka PM

where you have been stuck ? and her we are in doing Essay writing in uk




Senast redigerad 17:43 - 15:e Juli 2018


Emmagranger 07:57 - 18:e November 2017 | Post #6
Medlem
Inlägg: 1


Skicka PM

Programming commonly can be separated into two ideal models Pay Someone to Do my Essay which are question situated and practical programming.A utilitarian dialect is something like C that doesn't utilize classes or protests, it just uses capacities and information structures. Question Oriented Programming is diverse as in they for the most part make it simpler to track "occurrences". So in protest arranged programming you have something many refer to as a class, which wraps together capacities and factors into a solitary piece of code.




Senast redigerad 07:58 - 18:e November 2017


elianahermione12 07:22 - 23:e November 2017 | Post #7
Medlem
Inlägg: 1


Skicka PM

Programming and now I have composed a code in python that speaks to the amusement tic tac toe Be that as it may, it doesn't generally fill Online Essay Help in as I need the PC to endeavor to keep the other from winning and it ought to be a draw and that it will be printed It's a tie something comparable however I have not succeeded. Is there any individual who could help me with the code I've been battling for quite a while.




Senast redigerad 07:23 - 23:e November 2017


ElizaJabeen 14:24 - 2:a December 2017 | Post #8
Medlem
Inlägg: 2


Skicka PM

We are the best written work administration and help in UK that gives all sort of scholarly assignments to purchase through our very qualified ...




Senast redigerad 14:37 - 2:a December 2017


AhmedKhan 13:12 - 5:e Januari 2018 | Post #9
Medlem
Inlägg: 3


Skicka PM

Hey dear, I read your post and I think it is coding error so you should check the all program and also the computers may be, cause of some errors you are facing the problems and even if your problems not solve it so you can take help with PPT Design Service who is best assistance provider and also work in the programming field.






Sidor: 1

Forum huvudsida -> Programmering -> Python hjälp
Atom feed

Du får inte posta i den här tråden | Till toppen