CODE
As a full time, full stack software engineer, my day to day consists of programming and debugging large scale industry applications. But here are some of my more exciting projects from early in my coding career.
PacMan Agents AI
Python
The Pacman AI projects were developed at UC Berkeley. The core projects and autograders were primarily created by John DeNero (denero@cs.berkeley.edu) and Dan Klein (klein@cs.berkeley.edu). Student side autograding was added by Brad Miller, Nick Hay, and Pieter Abbeel (pabbeel@cs.berkeley.edu).
The aim of this project was to progressively create the search algorithms for depth first, breadth first, uniform cost, then A* search within a Pacman framework (provided by University of California Berkely). Beginning with position search problems, I moved to applying hueristics for "all corners" search probelms as well as search senarios with active ghosts to be considered and avoided.
My code can be found in the following functions in search.py:
depthFirstSearch
breadthFirstSearch
uniformCostSearch
aStarSearch
as well as in the following functions in searchAgents.py in the CornersProblem class:
getStartState
isGoalState
getSuccessors
cornersHeuristic
def aStarSearch(problem, heuristic=nullHeuristic):
"""Search the node that has the lowest combined cost and heuristic first."""
solved = 0
fringe = util.PriorityQueue()
explored = set()
# Node Structure
# Tuple (position,tuple([actions...]),cost)
startNode = (problem.getStartState(), [], 0)
fringe.push(startNode, heuristic(startNode[0], problem))
while solved == 0:
if fringe.isEmpty():
return "Failure"
# Remove next node from fringe
node = fringe.pop()
if problem.isGoalState(node[0]) == True:
return node[1] # solution path
# Expand the node and add its successors to the fringe
if (node[0] not in explored):
successors = problem.getSuccessors(node[0])
# Add the node's path to the explored set
explored.add(node[0])
for i in range(0, len(successors)):
newLocation = successors[i][0]
updatedPath = node[1] + [successors[i][1]]
newCost = node[2] + successors[i][2]
newNode = (newLocation, updatedPath, newCost)
fringe.push(newNode, (newCost+heuristic(newNode[0], problem)))
Socket Painter
Java
This project was to create a shared painting and chat surface to work between machines. The first piece was creating a stand alone GUI painter, the second was to integrate sockets and threads to allow the painters a connection across the internet. The paint panel updates in real time. As any of the users sends a chat or paints a shape, that message or shape appears to all other users on their respective machines. I coded this project in its entirety.
Here is the full Java File Set:
public abstract class PaintingPrimitive implements Serializable{
Color color;
public PaintingPrimitive(Color c){
this.color = c;
}
public final void draw(Graphics g){
g.setColor(color);
drawGeometry(g);
}
protected abstract void drawGeometry(Graphics g);
}
public class PaintingPanel extends JPanel{
static ArrayList<PaintingPrimitive> primitives = new ArrayList();
public PaintingPanel(){
//super();
this.setBackground(Color.WHITE);
}
public void addPrimitive(PaintingPrimitive obj){
PaintingPanel.primitives.add(obj);
}
public void paintComponent(Graphics g){
super.paintComponent(g);
for(PaintingPrimitive obj:primitives){
obj.draw(g);
}
}
}
public class Hub {
public static void main(String[] args) {
ArrayList<ObjectOutputStream> outStreams = new ArrayList<ObjectOutputStream>();
//ArrayList<Socket> painters = new ArrayList();
ArrayList<PaintingPrimitive> images = new ArrayList<PaintingPrimitive>();
ArrayList<Object> messages = new ArrayList<Object>();
try{
ServerSocket ss = new ServerSocket(7000);
while(true){
//System.out.println("Waiting for a call");
Socket s = ss.accept();
ObjectInputStream inst = new ObjectInputStream(s.getInputStream());
ObjectOutputStream outst = new ObjectOutputStream(s.getOutputStream());
outStreams.add(outst);
for(int i = 0; i < messages.size(); i++){
outst.writeObject(messages.get(i));
}
for(int i = 0; i < images.size(); i++){
outst.writeObject(images.get(i));
}
new Thread(new Runnable(){
public void run(){
try{
while(true){
Object read = inst.readObject();
if(read instanceof String){
messages.add(read);
}
else{
images.add((PaintingPrimitive)read);
}
for(int i = 0; i < outStreams.size();i++){
outStreams.get(i).writeObject(read);
}
}
}
catch(Exception e){
outStreams.remove(outst);
}
}
})
.start();
}
//ss.close();
}
catch (IOException e){
System.out.println(e.getMessage());
}
}
}