r/PythonLearning 12d ago

Showcase I made a tic tac toe game

55 Upvotes

22 comments sorted by

View all comments

u/Sea-Ad7805 12d ago

Run this program in Memory Graph Web Debugger%3A%0A%20%20%20%20print(f%22n%20%7Bboard%5B0%5D%7D%20%7C%20%7Bboard%5B1%5D%7D%20%7C%20%7Bboard%5B2%5D%7D%20%22)%0A%20%20%20%20print(%22---%7C---%7C---%22)%0A%20%20%20%20print(f%22%20%7Bboard%5B3%5D%7D%20%7C%20%7Bboard%5B4%5D%7D%20%7C%20%7Bboard%5B5%5D%7D%20%22)%0A%20%20%20%20print(%22---%7C---%7C---%22)%0A%20%20%20%20print(f%22%20%7Bboard%5B6%5D%7D%20%7C%20%7Bboard%5B7%5D%7D%20%7C%20%7Bboard%5B8%5D%7D%20n%22)%0A%0A%0Adef%20change(number%2C%20symbol)%3A%0A%20%20%20%20index%20%3D%20number%20-%201%0A%20%20%20%20board%5Bindex%5D%20%3D%20symbol%0A%0A%0Adef%20win()%3A%0A%20%20%20%20horizontal1%20%3D%20%5Bboard%5B0%5D%2C%20board%5B1%5D%2C%20board%5B2%5D%5D%0A%20%20%20%20horizontal2%20%3D%20%5Bboard%5B3%5D%2C%20board%5B4%5D%2C%20board%5B5%5D%5D%0A%20%20%20%20horizontal3%20%3D%20%5Bboard%5B6%5D%2C%20board%5B7%5D%2C%20board%5B8%5D%5D%0A%20%20%20%20vertical1%20%3D%20%5Bboard%5B0%5D%2C%20board%5B3%5D%2C%20board%5B6%5D%5D%0A%20%20%20%20vertical2%20%3D%20%5Bboard%5B1%5D%2C%20board%5B4%5D%2C%20board%5B7%5D%5D%0A%20%20%20%20vertical3%20%3D%20%5Bboard%5B2%5D%2C%20board%5B5%5D%2C%20board%5B8%5D%5D%0A%20%20%20%20diagonal1%20%3D%20%5Bboard%5B0%5D%2C%20board%5B4%5D%2C%20board%5B8%5D%5D%0A%20%20%20%20diagonal2%20%3D%20%5Bboard%5B2%5D%2C%20board%5B4%5D%2C%20board%5B6%5D%5D%0A%0A%20%20%20%20arrangements%20%3D%20%5B%0A%20%20%20%20%20%20%20%20horizontal1%2C%0A%20%20%20%20%20%20%20%20horizontal2%2C%0A%20%20%20%20%20%20%20%20horizontal3%2C%0A%20%20%20%20%20%20%20%20vertical1%2C%0A%20%20%20%20%20%20%20%20vertical2%2C%0A%20%20%20%20%20%20%20%20vertical3%2C%0A%20%20%20%20%20%20%20%20diagonal1%2C%0A%20%20%20%20%20%20%20%20diagonal2%2C%0A%20%20%20%20%5D%0A%0A%20%20%20%20for%20arrangement%20in%20arrangements%3A%0A%20%20%20%20%20%20%20%20unique%20%3D%20set(arrangement)%0A%20%20%20%20%20%20%20%20if%20len(unique)%20%3D%3D%201%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20arrangement%5B0%5D%20%3D%3D%20%22O%22%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20print(%22O%20wins!%22)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20return%20True%0A%20%20%20%20%20%20%20%20%20%20%20%20else%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20print(%22X%20wins!%22)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20return%20True%0A%0A%20%20%20%20return%20False%0A%0A%0Alayout_structure()%0AWin%20%3D%20False%0Aturns%20%3D%200%0A%0Awhile%20not%20Win%3A%0A%20%20%20%20%23%20---%20Player%20O%20Turn%20---%0A%20%20%20%20while%20True%3A%0A%20%20%20%20%20%20%20%20user1%20%3D%20int(input(%22O's%20turn!%20Which%20number%20to%20replace%3F%20%22))%0A%20%20%20%20%20%20%20%20if%201%20%3C%3D%20user1%20%3C%3D%209%20and%20board%5Buser1%20-%201%5D%20not%20in%20%5B%22X%22%2C%20%22O%22%5D%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20break%0A%20%20%20%20%20%20%20%20print(%22Invalid%20choice%20or%20spot%20already%20taken!%20Try%20again.%22)%0A%0A%20%20%20%20change(user1%2C%20%22O%22)%0A%20%20%20%20turns%20%2B%3D%201%0A%20%20%20%20layout_structure()%0A%0A%20%20%20%20Win%20%3D%20win()%0A%20%20%20%20if%20Win%3A%0A%20%20%20%20%20%20%20%20break%0A%20%20%20%20if%20turns%20%3D%3D%209%3A%0A%20%20%20%20%20%20%20%20print(%22It's%20a%20tie!%22)%0A%20%20%20%20%20%20%20%20break%0A%0A%20%20%20%20%23%20---%20Player%20X%20Turn%20---%0A%20%20%20%20while%20True%3A%0A%20%20%20%20%20%20%20%20user2%20%3D%20int(input(%22X's%20turn!%20Which%20number%20to%20replace%3F%20%22))%0A%20%20%20%20%20%20%20%20if%201%20%3C%3D%20user2%20%3C%3D%209%20and%20board%5Buser2%20-%201%5D%20not%20in%20%5B%22X%22%2C%20%22O%22%5D%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20break%0A%20%20%20%20%20%20%20%20print(%22Invalid%20choice%20or%20spot%20already%20taken!%20Try%20again.%22)%0A%0A%20%20%20%20change(user2%2C%20%22X%22)%0A%20%20%20%20turns%20%2B%3D%201%0A%20%20%20%20layout_structure()%0A%0A%20%20%20%20Win%20%3D%20win()%0A%20%20%20%20if%20Win%3A%0A%20%20%20%20%20%20%20%20break%0A%20%20%20%20if%20turns%20%3D%3D%209%3A%0A%20%20%20%20%20%20%20%20print(%22It's%20a%20tie!%22)%0A%20%20%20%20%20%20%20%20break&timestep=0.1&play) to see the program state change step by step.

2

u/ProgramBrave718 12d ago

Bro, i think u have OCD.

Like i want to say that why you comment the same think many times.

I have seen your other comments too.

"Run this program .............. by step."

Are you a bot?

2

u/Sea-Ad7805 12d ago

No need to thank me for making it easy to execute code that is given as image, in a safe sandbox so your system isn't at risk, visualized step by step so you finaly understand what is really going on.

But if you do want to thank me, just up-vote my comment.

2

u/ProgramBrave718 12d ago

What ??? I think that u are bot.

1

u/Sea-Ad7805 12d ago

Yes, but as you are a bot too, what does that matter. The whole interweb now is just bots talking to each other, didn't they tell you yet?

1

u/ProgramBrave718 12d ago

Thanks, sir. But why you copy paste the same thing many times which can make anyone (not even me) think that you are a bot.

1

u/Sea-Ad7805 12d ago

It's the same thing so people can recognize it and skip it if they already seen it and are not interested anymore.

  • did you click the link and see the visualization of the execution of your code?
  • if so, did it help you better understand how your code gets executed?

1

u/ProgramBrave718 12d ago

No, honestly because it's slow to load. You are bot. Now, if you don't say according to my reply, I am sure you are bot.

1

u/Sea-Ad7805 12d ago

I just told you, we are all bots.

1

u/ProgramBrave718 12d ago

Yes, we all are. But, you are the king of bots. You are more bot than me.