Today...

Still listening to Missy Higgins...
Labels: programming

Labels: programming


Labels: programming
Labels: programming
set up initial node velocities to (0,0)
set up initial node positions randomly // no 2 nodes are in exactly the same position
loop
total_kinetic_energy := 0 // total kinetic energy of all particles
for each nodenet_force := (0, 0) // running sum of node's total force
for each other node
net_force := net_force + Coulomb_repulsion( this_node, other_node )
next node
for each spring connected to this node
net_force := net_force + Hooke_attraction( this_node, spring )
next spring
// without damping, it moves foreverthis_node.velocity := (this_node.velocity + timestep * net_force) * damping
this_node.position := this_node.position + timestep * this_node.velocity
total_kinetic_energy := total_kinetic_energy + (this_node.velocity)^2
next node
until total_kinetic_energy is less than some small number //the simulation has stopped moving
The code doesn't really deal with crossing edges but naturally most of the crossings will resolve itself.
Labels: programming

Labels: programming
f = open('test.txt','r')
for line in f.read().split(','):
if i == 0:
z = line
print 'X1 = '+z
elif i == 1:
a = line
print 'a! = '+a
elif i == 2:
b = line
print 'b! = '+b
elif i == 3:
c = line
print 'c! = '+c
i = 0
i = i + 1
#training(x1, a, b, c)
f = open('test.txt','r')
linelist = f.readlines()
for line in linelist[1:]:
var=line.split(',')
print linelist[0].strip(),var[0],var[1],var[2]
Labels: programming
Labels: programming
Labels: programming




Labels: programming
Projek ni nak generate statistics for algorithm performance testing. Hence, the name 'AlgoAnalysis'. This is just a prototype but the random graph generator has been completed using python. This prototype tests if those classes can be called from a JAVA program which I have successfully demonstrated in the screenshot above as I use ANT to build my project.
import random
class Graph:
def __init__(self):
self.nodeIDList = []
self.nodeEdgelistDict = {}
self.nodeEdgelistWeightDict = {}
self.allowLoops = 0
self.allowMultipleEdges = 0
self.directedGraphType = 1
self.edgeWeightUpperLimit = 10
self.edgeWeightLowerLimit = -10
def generateGraph(self,nodeTotal,edgeTotal):
# add nodes first and define edge list
for currNodeCount in range(nodeTotal):
nodeID = self.getNextUniqueID()
self.nodeIDList.append(nodeID)
self.nodeEdgelistDict[nodeID] = []
.
.
.
package AlgoAnalysis;
import org.python.util.PythonInterpreter;
import org.python.core.*;
public class Graph {
private String variableName = "";
private PythonInterpreter interp = new PythonInterpreter();
public Graph(String newVariableName) throws PyException {
this.variableName=newVariableName;
interp.exec("import graphGenerator, graphAnalysis");
interp.exec(variableName+" = graphGenerator.Graph()");
}
public void generateGraph(int nodeTotal,int edgeTotal){
interp.exec(variableName+".generateGraph("+nodeTotal+","+edgeTotal+")");
}
public void toFile(String filename){
interp.exec(variableName+".toFile(\""+filename+"\")");
}
.
.
.

Labels: programming

Labels: programming

Labels: programming

Labels: programming

Labels: programming

Labels: programming

Labels: programming

Labels: programming



Labels: programming

| Up Arrow key | Accelerate |
| Down Arrow key | Reverse |
| Left Arrow key | Turn left |
| Right Arrow key | Turn right |
| Space bar | Brake |
| w | Move camera up |
| s | Move camera down |
| a | Move camera right |
| d | Move camera left |
| q | Adjust lens (zoom in) |
| e | Adjust lens (zoom out) |
| c | Cycle through cameras 1 default cam 2 rear cam 3 top(ortho) cam 4 static cam |
Labels: programming
Improved version of the game. I made a car using blender. Marwan kata ada rupa cam kereta Tamiya sikit. hmm . Maybe he's right ...Labels: programming