• AZOM

    I’m searching for a way to see if the numbers in a list = the numbers in a dictionary key. EX: dictionary = {12345:6, 01928:7} list = [1, 2, 3]. And the output would be like: the list fit in the key 12345.

    posted in Pythonista read more
  • AZOM

    Hi, I am creating a Pythonista server to talk about it. Come in and help it get better. Thank you

    Link: https://discord.gg/j343ytM

    posted in General Discussion read more
  • AZOM

    Now, the last thing I need is to click a view programmatically.

    posted in Pythonista read more
  • AZOM

    I’m not trying to do one (I’ve already done) I’m am searching for a random int (I know how to do this part xp) but when it finds a int, how do I make that it press the good view on the screen.

    posted in Pythonista read more
  • AZOM

    Hi, I’m doing a code (at the end of the text) on a tic-tac-to project, I’m searching to do an AI, but I am wondering how I make my AI (at the beginning I want him to be random) that press on the « views » that I made.

    Code (I don’t know why it shows without indent btw):

    import ui
    import time
    import random
    
    CaseTouche = None
    turn = 0
    matrix = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
    won = None
    
    class case(ui.View):
        def touch_ended(self, touch):
            global turn
            global CaseTouche
            if CaseTouche != None:
                CaseTouche.border_color = "black"
            CaseTouche = self
            self.border_color = "blue"
            x = int(self.name[0])
            y = int(self.name[1])
            if matrix[x][y] == 0:
                if turn == 0:
                    self.background_color = "green"
                    turn = 1
                    matrix[x][y] = 1
                elif turn == 1:
                    self.background_color = "red"
                    turn = 0
                    matrix[x][y] = 2
                won = verificationwin(matrix)
                if won == True:         
                    col = self.background_color
                elif won == False:
                    col = "black"
                if won != None:
                    sv = self.superview
                    for v in sv.subviews:
                        v.background_color = col
                won = None
                
                    
                
    def verificationwin(matrix):
        if matrix[0][0] == matrix[0][1] == matrix[0][2] > 0:
            return True
        elif matrix[1][0] == matrix[1][1] == matrix[1][2] > 0:
            return True
        elif matrix[2][0] == matrix[2][1] == matrix[2][2] > 0:
            return True
        elif matrix[0][0] == matrix[1][0] == matrix[2][0] > 0:
            return True
        elif matrix[0][1] == matrix[1][1] == matrix[2][1] > 0:
            return True
        elif matrix[0][2] == matrix[1][2] == matrix[2][2] > 0:
            return True
        elif matrix[0][0] == matrix[1][1] == matrix[2][2] > 0:
            return True
        elif matrix[0][2] == matrix[1][1] == matrix[2][0] > 0:
            return True
        elif matrix[0][0] and matrix[0][1] and matrix[0][2] and matrix[1][0] and matrix[1][1] and matrix[1][2] and matrix[2][0] and matrix[2][1] and matrix[2][2] > 0:
            return False
    
    v = ui.load_view('tictactac')
    v.present()
    

    posted in Pythonista read more
  • AZOM

    Ok, I’m going to do some stuff about it and if I get a problem I will come back another day I guess.

    posted in Pythonista read more
  • AZOM

    Do you want me to send it to you by discord or something like that?

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!