def Populate(Board, Mode):
    ColourOps = ["P", "B", "G", "O", "R", "Y"]
    #Index = random.randint(0,5)
    xMove = 48
    yMove = 48
    Valid = False

    if Mode == "Normal":
        Normal = open("No Matches Board Colours.txt", "r")
        Index = 1
        FileContents = []
        for line in Normal:
            FileContents.append(line)

        for j in range(9):
            for i in range(9):
                """Index = random.randint(0,5)
                    Col = ColourOps[Index]""" #Original
                Index += 1
                Col = ColourOps[int(FileContents[Index])]
                Board[i][j] = Jar.Sweet(Col, i, j, Board)

    elif Mode == "Random":
        for j in range(9):
            for i in range(9):
                Index = random.randint(0, 5)
                Col = ColourOps[Index]
                Board[i][j] = Jar.Sweet(Col, i, j, Board)

    for a in range(2):
        for j in range(9):
            for i in range(9):
                MatchX = CheckSides(Board[i][j], 0)
                MatchY = CheckSides(Board[i][j], 2)
                if MatchX[0] >= 3 or MatchY[0] >= 3:  #check how many matched
                    Col = Board[i][j].getColour()
                    if Board[i][j].getColour() == Col:
                        Index = random.randint(0, 5)
                        Col = ColourOps[Index]
                        Board[i][j] = Jar.Sweet(Col, i, j, Board)
    Board[i][j] = Jar.ColourBomb("D", i, j, Board)
    Board[i - 1][j] = Jar.Striped("R", i - 1, j, Board, "H")
    Board[i - 2][j] = Jar.Wrapped("B", i - 2, j, Board)
Пример #2
0
    def __enQueue(self):  #Private Function, shouldn't be called in main
        ColourOps = ["P", "B", "G", "O", "R", "Y"]
        Index = random.randint(0, 5)
        Col = ColourOps[Index]

        if self.isFull():
            print("The array is full, cannot append soz")

        elif not self.isFull():
            self.CurrentSize = self.CurrentSize + 1
            self.Q[self.Rear + 1] = Jar.Sweet(Col, self.i, self.j, self.Board)
            self.Rear = self.Rear + 1

            if self.Rear == (self.MaxSize - 1):
                self.Rear = -1

        return self.Q