下面是我必須創建的簡單遊戲的Python代碼,現在我難以分開代碼來使用套接字在客戶端和服務器上玩遊戲。任何幫助,將不勝感激客戶端服務器上的Python遊戲
import random
rannum = random.randrange(0,10,1)
print rannum
counter = 0
a=0
while(a==0):
guess = int(raw_input("What is your guess?: "))
counter = counter + 1
diff = abs(guess - rannum)
if(diff >5):
print "Way Off!"
elif(diff >2):
print "Close!"
elif (diff>1):
print "Closer!"
elif(diff >0):
print "Even Closer!"
elif (diff==0):
print "Correct"
name = str(raw_input("What is your name?: "))
print name + " Your score is: "
print counter
f = open('high_scores.txt', 'a')
score = str(counter)
f.write(name + " " + score + "\n")
f.close()
break
你的問題是什麼?你剛剛粘貼你的代碼,並基本上說「幫助我!」。 – Willy
,因爲我不確定如何分離用戶界面和遊戲邏輯以及確保它在客戶端服務器體系結構上運行的特定代碼 –