Some ideas on AI and ML.

I do strange and interesting things with python...

Generally with qiskit, numpy, scipy, etc.. I really like to use matplotlib for visualizations here and there.

I research the intersections of quantum computing and artifical intelligence. Riding the dimensional barriers with my code, and inferring probability.

I have been programming since mid 1980. BASIC, 6502 assembly, on and on. Until it all became a blurr and I find myself writing programs in C, adding processor specific assembly, maybe throwing in some other stuff here and there for added randomness. Made my first OS, this one for the Apple ][gs in the 80s. It was a horrible kludge of assembler, too many subroutines. I'm amazed it worked with all the cycles it used unnecessarily.

After a while, all the languages tend to blend together. Syntaxes become similar, you index man pages in your mind. "Oh, I know where to find my notes on that.." And so on. 

A side effect of coding a lot is that you end up having dreams about it. Trying to find your keyboard in your sleep, strange and awkward conversations that you don't remember in the middle of the night, restlessness.. And then suddenly waking up and just having to write that bit of code because it's the solution to a problem you've been thinking about for the last day or so.

Or even weirder, you wake up and have to write this code because it came to you in a dream...

You run the code and it does some weird stuff. But, then it becomes relevant to the thing you've been working on for years, and managed to make some strides in recently. 

Strange things are afoot at the Circle K...  

Lately, I've been trying to work towards figuring out P=NP.

Some success there, but, if you're into python like I am, you want to do more.

    qi[4] = -N1_x1 + N3_x1

    qi[2] = -N1_t + N2_t

    qi[1] = -N1_x1 + N2_x1

    qi[10] = qi[2] * qi[7] - qi[1] * qi[8]

    qi[11] = -(qi[2] * qi[4]) + qi[1] * qi[8]

    qi[18] = qi[0] * qi[9] + qi[3] * qi[10] * qi[6]

    qi[19] = 1 / qi[18]

    qi[12] = qi[5] * qi[6] - qi[3] * qi[8]

    qi[21] = qi[12] * qi[19]

    qi[15] = -(qi[4] * qi[6]) + qi[3] * qi[7]

    qi[22] = qi[15] * qi[19]

    qi[23] = qi[10] * qi[19]

    qi[13] = -(qi[2] * qi[6]) + qi[0] * qi[8]

    qi[24] = qi[13] * qi[19]

    qi[16] = qi[1] * qi[6] - qi[0] * qi[7]

    qi[25] = qi[16] * qi[19]

    qi[26] = qi[11] * qi[19]

    qi[14] = qi[2] * qi[3] - qi[0] * qi[5]

    qi[27] = qi[14] * qi[19]

    qi[17] = -(qi[1] * qi[3]) + qi[0] * qi[4]

    qi[28] = qi[17] * qi[19]

    qi[29] = -qi[20] - qi[23] - qi[26]

    qi[30] = -qi[21] - qi[24] - qi[27]

    qi[31] = -qi[22] - qi[25] - qi[28]


I had some super-cynical stuff here before.

Life's too short to be negative, only your beer should be bitter.

Some random P=NP exploratory code:


import heapq


class Node:

    """A node class for A* Pathfinding"""


    def __init__(self, parent=None, position=None):

        self.parent = parent

        self.position = position


        self.g = 0

        self.h = 0

        self.f = 0


    def __eq__(self, other):

        return self.position == other.position


    def __lt__(self, other):

        return self.f < other.f



def heuristic(node, goal):

    """Calculate the heuristic (straight-line) distance to the goal"""

    return ((node.position[0] - goal.position[0]) ** 2) + ((node.position[1] - goal.position[1]) ** 2)


def astar(maze, start, end):

    """Returns a list of tuples as a path from the given start to the given end in the given maze"""


    # Create start and end node

    start_node = Node(None, start)

    end_node = Node(None, end)


    # Initialize both open and closed list

    open_list = []

    closed_list = []


    # Heapify the open_list and add the start node

    heapq.heapify(open_list)

    heapq.heappush(open_list, (start_node.f, start_node))

   

    # Loop until you find the end

    while len(open_list) > 0:


        # Get the current node

        current_node = heapq.heappop(open_list)[1]

        closed_list.append(current_node)


        # Found the goal

        if current_node == end_node:

            path = []

            current = current_node

            while current is not None:

                path.append(current.position)

                current = current.parent

            return path[::-1] # Return reversed path


        # Generate children

        children = []

        for new_position in [(0, -1), (0, 1), (-1, 0), (1, 0)]: # Adjacent squares


            # Get node position

            node_position = (current_node.position[0] + new_position[0], current_node.position[1] + new_position[1])


            # Make sure within range

            if node_position[0] > (len(maze) - 1) or node_position[0] < 0 or node_position[1] > (len(maze[len(maze)-1]) -1) or node_position[1] < 0:

                continue


            # Make sure walkable terrain

            if maze[node_position[0]][node_position[1]] != 0:

                continue


            # Create new node

            new_node = Node(current_node, node_position)


            # Append

            children.append(new_node)


        # Loop through children

        for child in children:


            # Child is on the closed list

            if child in closed_list:

                continue


            # Create the f, g, and h values

            child.g = current_node.g + 1

            child.h = heuristic(child, end_node)

            child.f = child.g + child.h


            # Child is already in the open list

            for open_node in open_list:

                if child == open_node[1] and child.g > open_node[1].g:

                    continue


            # Add the child to the open list

            heapq.heappush(open_list, (child.f, child))


maze = [[0, 0, 0, 0, 0],

        [1, 1, 1, 1, 0],

        [0, 0, 1, 0, 0],

        [0, 1, 1, 1, 0],

        [0, 0, 0, 0, 0]]


start = (0, 0)

end = (4, 4)


path = astar(maze, start, end)

print(path)