not good

This program has been disqualified.


AuthorThe even worse terminator
Submission date2019-02-14 14:58:20.952449
Rating4990
Matches played54
Win rate48.15

Source code:

bfs_dfs = 1


class node:
    def __init__(self, object, children = []):
        self.object = object
        self.children = children


class tree:
    def __init__(self):
        self.root = node("", [])
        self.add(self.root, 5)

    def add(self, curry, depth):
        if depth > 0:
            depth = depth - 1
            curry.children = [node(curry.object + "R"), node(curry.object + "P"), node(curry.object + "S")]
            self.add(curry.children[0], depth)
            self.add(curry.children[1], depth)
            self.add(curry.children[2], depth)
            return 0

    def getRoot(self):
        return self.root


def search(bfs_dfs, node):
    if bfs_dfs == 0:
        return bfs(node)
    else:
        return dfs(node)


def bfs(root):
    sequence = []
    moves = [root]
    while moves:
        node = moves[0]
        moves = moves[1:]
        if node.object != "":
            sequence.append(node.object)
        for x in node.children:
            moves.append(x)
    return sequence


def dfs(root):
    sequence = []
    moves = [root]
    while moves:
        node = moves[0]
        moves = moves[1:]
        if node.object != "":
            sequence.append(node.object)
        kids = node.children[:]
        kids.reverse()
        for x in kids:
            moves.insert(0, x)
    return sequence


def beat(play):
    if play == "R":
        return "P"
    elif play == "P":
        return "S"
    else:
        return "R"


if not input:
    pos = 3
    pos_array = 1
    lastPlay = ""
    repeat = 0
    output = "R"
else:
    if lastPlay == "":
        output = search(bfs_dfs, tree().getRoot())[pos][pos_array]
        pos_array += 1
    elif input == lastPlay:
        repeat = 1
        output = beat(input)
        doubletest = 0
    else:
        if repeat == 0:
            if pos_array < len(search(bfs_dfs, tree().getRoot())[pos]):
                output = search(bfs_dfs, tree().getRoot())[pos][pos_array]
                pos_array += 1
            else:
                pos += 1
                pos_array = 0
                output = search(bfs_dfs, tree().getRoot())[pos][pos_array]
                pos_array += 1
        else:
            if doubletest == 1:
                repeat = 0
            if pos_array < len(search(bfs_dfs, tree().getRoot())[pos]):
                output = search(bfs_dfs, tree().getRoot())[pos][pos_array]
                pos_array += 1
                if pos_array == len(search(bfs_dfs, tree().getRoot())[pos]):
                    doubletest = 1
            else:
                pos_array = 0
                output = search(bfs_dfs, tree().getRoot())[pos][pos_array]
                pos_array += 1
    lastPlay = input