Jump to content
Slark

x si o python

Recommended Posts

Posted

Salut!.

de 2 zile m-am apucat sa invat python.

am reusit sa fac un joc de x si o.. toate bune si frumoase dar nu stiu cum sa fac sa verifice daca ii "remiza"

fiserul .py ii aici GirlShare - Download x si o.py

m-am uitat pe google dar nu inteleg mare lucru..

inca nu am ajuns la def / for

dar ma gandesc ca merge si fara (cred) din moment ce tot functioneaza bine inafar de "remiza"

Posted

Faci in felul urmator. Pui o variabila counter care tine cont de cate mutari au avut loc, pe care o incrementezi de fiecare data cand un jucator alege.

Daca counter ajunge sa fie egal cu 9 si nu este niciun castigator atunci este remiza.

Posted (edited)

gata mi-am dat seama.

fac asa (sau cu remiza += 1) nu conteaza ori cum.


if user == '1' and cas[0] == '1':
cas[0] = jucator
remiza = remiza + 1
elif user == '2' and cas[1] == '2':
cas[1] = jucator
remiza = remiza + 1
elif user == '3' and cas[2] == '3':
cas[2] = jucator
remiza = remiza + 1
elif user == '4' and cas[3] == '4':
cas[3] = jucator
remiza = remiza + 1
elif user == '5' and cas[4] == '5':
...etc

iar variabila remiza declarata afar din bucla (logic)

si undeva mai jos

if remiza >= 9:

mersi tjt.

ma gandesc ca merge.. momentan nu sunt acas sa probez

EDIT: Da merge!

Edited by Slark

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...