We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProcessing DevelopmentLibraries,  Tool Development › Artificial Intelligence Library
Page Index Toggle Pages: 1
Artificial Intelligence Library (Read 7731 times)
Artificial Intelligence Library
Jun 16th, 2006, 1:10pm
 
Thanks to scloopy I can make a start on this. I intend to feature the following as accessible objects in a compiled package. I want to build them so people can pretty much use them in a very abstract way. I lot of it is based on borrowed code so I will be rewriting a lot of it to make it more mine and more universal.

A*

Genetic Algorithm

Neural Nets

Especially with things like A* which has derivatives like Djikstra's, BFS and the sum of directions for the search there will be a lot of scope for variation. The neural nets I'm going to have to add one by one, probably starting with Back Propagation because it's the most useful.

Suggestions for other things I could add would be very helpful. I will add to this thread when I get the first basic components compiled and the documentation online.
Re: Artificial Intelligence Library
Reply #1 - Sep 7th, 2006, 12:30pm
 
Looks nice!
docs would be great indeed.
Im working on some clustering algorithms (agglometric clustering) for colors, but its quite generic, so it can cluster most things.  could maybe be a good addition to your lib?
only that it is written in java 5.0, does processing support that?

cheers

h
Re: Artificial Intelligence Library
Reply #2 - Sep 7th, 2006, 6:01pm
 
Yeah, I'm running 5.0 anyway, but there are some issues with various things. Try searching the board for Java 1.42 or summink like that and there's various suggestions to certain bugs that can be solved by rolling back the Java. Not my problem so far.

Additions are more than welcome. I'm unemployed and trying to get some prints made for portfolio purposes as well as for possible exhibitions. I'm working on a piece right now to try to iron out the issues with the Genetic Algorithm library.

There's also stuff like the following links I got from talks in Prague I'd like to implement

Flocking behaviours and a **** load of AI links

Crowd motion

D* pathfinding (whatever the hell that may be - haven't got round to reading it yet)

Netlogo has a wealth of Artificial Life models on it. Some of the stuff like Ants I thought would have great potential for some art projects.

I am basically biting off my than I can chew here (gerbil trying to chow down a Buick if you need a scale comparision). The phrase, "anytime soon", really does not apply. But my major weakness is that I always make good on my drunken boasts. Eventually.
Re: Artificial Intelligence Library
Reply #3 - Sep 21st, 2006, 6:04pm
 
After a few months of me in front of a vdu going like this...

Genetic Algorithm Library

I heartily expect none of you buggers to use it. And yes there is documentation, hence I'm pretty snarky today.

Next: AStar
Re: Artificial Intelligence Library
Reply #4 - Oct 5th, 2006, 9:58pm
 
Re: Artificial Intelligence Library
Reply #5 - Oct 13th, 2006, 11:04pm
 
I'm listing the contents of this project at the following url. Links to AStar and GA are there, as will be the rest of the blah in time to come.

http://www.robotacid.com/PBeta/AILibrary/

I've a Flash portfolio to work on and then I'll be working on the BPN. That's going to be a weird one because I'm not sure how it'll pan out in floats and I have to come up with a project to test it.

Still had zero feedback on the AStar but as I'm discovering, A.I. just lacks the plug and play angle. That's probably why diverse libraries are lacking. If people aren't happy with my array-vector system then I'd be happy to integrate it with an existing library like Shiffman's Vector3D. Just say the word.
Re: Artificial Intelligence Library
Reply #6 - Jan 16th, 2007, 7:28pm
 
Pathfinder Library

This replaces the AStar library and is somewhat different to operate (and somewhat faster and easier). aStar(), bfs() and dijkstra() methods now exist to offer a range of navigation tools.

Nodes are now joined by Connector objects. This was necessary to make Dijkstra work because the Nodes in a Dijkstra search don't have a spatial location just a length of wire between them. However - the old Carden/Steed algorithm calculated distances every time it needed to find 'g', with Connectors it doesn't need to. That's a lot of calculations done away with.

I've also optimised the crap out of it. Nodes are located by simple x, y, z properties (no more arrays for location - they are slow). Pathfinder detects if Nodes both have z set to 0.0f and optimises distance calculations for the 2D user. ArrayLists - also faster. Home-grown indexing methods over Java methods - also faster.

I hope to build a kind of Bot class for it to make developing a way-point system for games easier. Moving less than a Node at a time requires some special trick. Right now I can't get my head round it and that means a week or so of developing time.

PS: Genetic Algorithm Library has had it's package name changed to ai.ga. The AI Libraries set will generally follow the ai.name system from now on.
Re: Artificial Intelligence Library
Reply #7 - Feb 22nd, 2007, 4:35pm
 
For those Flash-heads out there I've just converted the Carden / Steed AStar classes for Flash.

Download classes and demo fla

It's 2D only and simplified for indexing nodes on a grid (3D can be easily implemented and no Connector class in this one). I'm using it to build a game I thought of for the Telic exhibit.

View game engine mock up (with juicy bugs an' all)

I imagine there are people who have made faster A* for Flash and I've looked briefly at them, but none of them I feel take care of things like building square paths around objects and using the arrays of Nodes in Nodes that Tom came up with. The zip is also available on the Pathfinder library page.

It's AS2.0 compatible, so if I've forgotten to backdate the version on the files just mail me.
Pathfinder_Dijkstra
Reply #8 - Sep 16th, 2007, 7:42pm
 
I made a tiny variation of <Pathfinder_Dijkstra.pde> from the Pathfinder library.
It just put some colors on the connectors.

//from http://robotacid.com/
//from http://www.robotacid.com/PBeta/AILibrary/Pathfinder/index.html

// Demo of Dijkstra algorithm

import ai.pathfinder.*;

Pathfinder dijk;
int w = 10;
int h = 10;
boolean colored=true;
int spacing,s;
PFont font;

void setup(){
 size(400, 400);
 size(400, 400);
 spacing = width / w;
 s = spacing / 2;
 smooth();
 dijk = new Pathfinder(w, h, 1.0);
 font = loadFont("ArialMT-10.vlw");
 textFont(font, 10);
}

void draw(){
 background(230);
 fill(255);
 int m = (mouseX/spacing) + (mouseY/spacing) * w;
 rect((m % w) * spacing, (m / w) * spacing, spacing, spacing);
 drawConnectors();
 drawNodes();
}

void mousePressed(){
 int m = (mouseX/spacing) + (mouseY/spacing) * w;
 Node n = (Node)dijk.nodes.get(m);
 dijk.dijkstra(n);
}

void drawNodes(){
 for(int i = 0; i < dijk.nodes.size(); i++){
   Node n = (Node)dijk.nodes.get(i);
   Node p = null;
   int pnum = -1;
   if(n.parent != null){
     p = n.parent;
     pnum = dijk.indexOf(p);
   }
   int x = i % w;
   int y = i / w;
   int s = spacing / 2;
   if(p != null){
     int px = pnum % w;
     int py = pnum / w;
     int xDelta=px-x;
     int yDelta=py-y;
     strokeWeight(1.5);
     //choose connection color
     if (colored) {
       int rCol=0,gCol=0,bCol=0;
       if (xDelta<0) rCol=255;
       else if (xDelta>0) rCol=0;
       else rCol=127;
       if (yDelta<0) bCol=255;
       else if (yDelta>0) bCol=0;
       else bCol=127;
       stroke(rCol, gCol, bCol);
     }
     else stroke(10);
     line(s + x * spacing, s + y * spacing, s + lerp(x, px, .8) * spacing, s + lerp(y, py, .8) * spacing);
   }
   strokeWeight(1);
   stroke(10);
   fill(255);
   ellipse(s + x * spacing, s + y * spacing, 10, 10);
   fill(0);
   text(nf(n.g, 2, 1), 10 + x * spacing, 10 + y * spacing);
 }
}
void drawConnectors(){
 stroke(200, 200, 250);
 for(int i = 0; i < dijk.nodes.size(); i++){
   Node n = (Node)dijk.nodes.get(i);
   int cnum = -1;
   for(int j = 0; j < n.links.size(); j++){
     Connector c = (Connector)n.links.get(j);
     cnum = dijk.indexOf(c.n);
     int x = i % w;
     int y = i / w;
     int cx = cnum % w;
     int cy = cnum / w;
     line(s + x * spacing, s + y * spacing, s + cx * spacing, s + cy * spacing);
   }
 }
}
Re: Artificial Intelligence Library
Reply #9 - Mar 15th, 2009, 6:28am
 
Hi St33d, the link to your AI library has not been accessible for a while. When can we expect the robotacid.com website up and running. Looking forward to explore the library.
Cheers,
Page Index Toggle Pages: 1