Patrick Hagmann

Backend Developer



I am a Backend developer seeking new employment at a good company in the California area. I am fluent with Ruby on Rails and have lots of experience working with Python and Javascript.

Resume



Personal Web Applications

Chess

A dynamic two player Chess Website implemented by me and 4 other developers using a Team Agile (Scrum) approach. My contributions were selecting and moving pieces, displaying all legal moves including if the king is in check, checking for checkmate, and maintaining the database using Firebase.


Texas Holdem

This app is still a work in progress. Currently the game supports a functional single player mode vs two computers. Used Javascript to deal the cards out and show each card on the river flip when all betting on the table is the same. Also jQuery supports a sliding bar to place various raises. Long term goals are to enhance AI capabilities, support multible players, and install a payment processing feature called Dwolla into the app.


Python Pokemon

My first complete desktop app project. Features a two Pokemon Trainers with 6 random Pokemon each. Features all moves and pokemon inside Generation I. Also includes the ability to switch out a pokemon from the battlefield to one in your arsenal. The AI trainer is implemented with a Machine Learning Algorithm called Nonlinear Conjugate Gradient Method.


Connect Four

A Website where you can play connect four vs a computer opponent. The winning move is shown with a blue line!


Coding Sample


Tree Search With Alpha Beta Pruning

Creates a Tree structure which can specify depth and how many leaf nodes each parent node has.

require 'pp'
class Node
attr_accessor :value, :next_node, :previous, :alpha, :beta, :pruned
    def initialize( next_node = nil, previous= [], alpha = - 1.0/0 , beta = 1.0/0, pruned = 0  )
        self.next_node = next_node
        self.previous = previous
        self.alpha = alpha
        self.beta = beta
        self.pruned = pruned
    end

end
class Tree
    attr_accessor :currentNode, :depth
    def initialize(currentNode=nil, depth=0)
      self.currentNode = currentNode
      self.depth = depth
    end

    def PreviousNodeAt(index)
        return self.currentNode.previous[index]
    end

    def PreviousSetLength
        return self.currentNode.previous.length
    end

    def PreviousValues
        set = []
        (0..(this.currentNode.previous.length -1)).each do |i|
            set << self.PreviousNodeAt(i).value
        end
        return set
    end

    def Next 
        self.currentNode.previous = []
        self.currentNode = self.currentNode.next_node
        self.depth -= 1
    end

    def Value
        return self.currentNode.value
    end

    def newadd(value)
        node = Node.new
        node.value = value
        if self.currentNode == nil
            self.currentNode = node
            self.depth += 1
            return
        end

        node.next_node = self.currentNode
        self.currentNode.previous.push(node)
        self.depth += 1
        self.currentNode = node
        self.currentNode.alpha = self.currentNode.next_node.alpha
        self.currentNode.beta = self.currentNode.next_node.beta
        return



    end

    def add(value)
        node = Node.new
        node.value = value
        node.next_node = self.currentNode
        self.currentNode.previous.push(node)
        return
    end

    def getDepth
        return self.depth
    end


    def ifPrune
        if self.currentNode.alpha >= self.currentNode.beta then return true else return false end
    end

    def getAlphaBeta(depth, index)
        if depth % 2 == 0
            if self.PreviousNodeAt(index).value < self.currentNode.beta
                self.currentNode.beta = self.PreviousNodeAt(index).value
                self.currentNode.value = self.currentNode.beta
            end

        else
            if self.PreviousNodeAt(index).value > self.currentNode.alpha
                self.currentNode.alpha = self.PreviousNodeAt(index).value
                self.currentNode.value = self.currentNode.alpha
            end

        end

    end

    def moveAlphaBetaUp(depth)
        if depth % 2 == 0
            if self.currentNode.beta > self.currentNode.next_node.alpha
                self.currentNode.next_node.alpha = self.currentNode.beta
                self.currentNode.next_node.value = self.currentNode.next_node.alpha
            end

        else
            if self.currentNode.alpha < self.currentNode.next_node.beta
                self.currentNode.next_node.beta = self.currentNode.alpha
                self.currentNode.next_node.value = self.currentNode.next_node.beta
            end

        end

    end





end





def AplhaBetaPruning(childern, depth)
    q = Tree.new
    q.newadd(nil)
    countdown = childern
    while countdown > 0
        
        if q.PreviousSetLength < childern - q.currentNode.pruned && q.getDepth < depth - 1 
            if q.ifPrune
                q.currentNode.pruned += 1
                next
            end

            q.newadd(nil)
            next

        elsif q.getDepth >= depth - 1
            z = 0
            while childern-1 >= z
                r = 1 + rand(100)
                q.add(r)
                if q.ifPrune
                    q.getAlphaBeta(q.getDepth,z)
                    break
                end
                q.getAlphaBeta(q.getDepth,z)
                z += 1
            end
            q.moveAlphaBetaUp (q.getDepth)
            q.Next

        else
            
            q.moveAlphaBetaUp (q.getDepth)
            q.Next

        end


        if q.currentNode.next_node == nil
            countdown -= 1
            if countdown <= 0
                puts "win"
                puts q.Value
                return q.depth
            end
            q.newadd(nil)
        end


    end

return 


end

pp AplhaBetaPruning(4, 12)



Email Contact
phagmann1@gmail.com