polycasso-commit Mailing List for polycasso (Page 8)
Brought to you by:
dbrosius
You can subscribe to this list here.
| 2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(115) |
Dec
(92) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2010 |
Jan
(6) |
Feb
|
Mar
|
Apr
|
May
|
Jun
(3) |
Jul
|
Aug
|
Sep
(1) |
Oct
(4) |
Nov
|
Dec
|
| 2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(13) |
Aug
(3) |
Sep
|
Oct
|
Nov
|
Dec
|
| 2012 |
Jan
(2) |
Feb
|
Mar
(2) |
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <dbr...@us...> - 2009-11-28 00:52:11
|
Revision: 75
http://polycasso.svn.sourceforge.net/polycasso/?rev=75&view=rev
Author: dbrosius
Date: 2009-11-28 00:52:03 +0000 (Sat, 28 Nov 2009)
Log Message:
-----------
top directory for release tags
Added Paths:
-----------
tags/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2009-11-27 20:59:51
|
Revision: 74
http://polycasso.svn.sourceforge.net/polycasso/?rev=74&view=rev
Author: dbrosius
Date: 2009-11-27 20:59:43 +0000 (Fri, 27 Nov 2009)
Log Message:
-----------
if the change is as good as the best (unlikely), do the change to shake it up
Modified Paths:
--------------
trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java 2009-11-27 20:43:59 UTC (rev 73)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java 2009-11-27 20:59:43 UTC (rev 74)
@@ -164,7 +164,7 @@
boolean newBest = false;
synchronized(lock) {
attempt++;
- if (delta < bestScore) {
+ if (delta <= bestScore) {
bestData = data.toArray(new PolygonData[data.size()]);
bestScore = delta;
if (Polycasso.DEBUG)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2009-11-27 20:44:16
|
Revision: 73
http://polycasso.svn.sourceforge.net/polycasso/?rev=73&view=rev
Author: dbrosius
Date: 2009-11-27 20:43:59 +0000 (Fri, 27 Nov 2009)
Log Message:
-----------
show true percentage
Modified Paths:
--------------
trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementTypeStats.java
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementTypeStats.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementTypeStats.java 2009-11-27 19:41:09 UTC (rev 72)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementTypeStats.java 2009-11-27 20:43:59 UTC (rev 73)
@@ -108,7 +108,7 @@
StringBuilder sb = new StringBuilder(100);
for (Map.Entry<ImprovementType, Stats> entry : typeStats.entrySet()) {
Stats stat = entry.getValue();
- sb.append(" ").append(entry.getKey().name()).append("% = ").append(stat.pct);
+ sb.append(" ").append(entry.getKey().name()).append("% = ").append(stat.pct * 100);
}
return sb.toString();
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2009-11-27 19:41:19
|
Revision: 72
http://polycasso.svn.sourceforge.net/polycasso/?rev=72&view=rev
Author: dbrosius
Date: 2009-11-27 19:41:09 +0000 (Fri, 27 Nov 2009)
Log Message:
-----------
add more debugging
Modified Paths:
--------------
trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementTypeStats.java
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementTypeStats.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementTypeStats.java 2009-11-27 19:39:00 UTC (rev 71)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementTypeStats.java 2009-11-27 19:41:09 UTC (rev 72)
@@ -66,6 +66,11 @@
stats.totals++;
failureRun = successful ? 0 : failureRun + 1;
if (failureRun > MAX_FAILURE_RUN) {
+ if (Polycasso.DEBUG){
+ System.out.println("** Stats at time of failure run **");
+ System.out.println(this);
+ System.out.println("**********************************");
+ }
initStats();
} else {
stats.pct = ((double)stats.successes) / ((double) stats.totals);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2009-11-27 19:39:11
|
Revision: 71
http://polycasso.svn.sourceforge.net/polycasso/?rev=71&view=rev
Author: dbrosius
Date: 2009-11-27 19:39:00 +0000 (Fri, 27 Nov 2009)
Log Message:
-----------
rollback keeping of overall stats, as that is not what is needed, we need sum of individual stats
Modified Paths:
--------------
trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementTypeStats.java
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementTypeStats.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementTypeStats.java 2009-11-27 19:32:52 UTC (rev 70)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementTypeStats.java 2009-11-27 19:39:00 UTC (rev 71)
@@ -40,8 +40,6 @@
return successes + "/" + totals + " [" + pct + "]";
}
}
- private int overallSuccesses = 1;
- private int overallTotals = 1;
private Map<ImprovementType, Stats> typeStats = new EnumMap<ImprovementType, Stats>(ImprovementType.class);
private Random r = new Random();
@@ -64,10 +62,8 @@
Stats stats = typeStats.get(type);
if (successful) {
stats.successes++;
- overallSuccesses++;
}
stats.totals++;
- overallTotals++;
failureRun = successful ? 0 : failureRun + 1;
if (failureRun > MAX_FAILURE_RUN) {
initStats();
@@ -85,7 +81,10 @@
public ImprovementType getRandomImprovementType() {
double pct = r.nextDouble();
- double totalPct = ((double) overallSuccesses) / ((double) overallTotals);
+ double totalPct = 0.0;
+ for (Stats stat : typeStats.values()) {
+ totalPct += stat.pct;
+ }
for (Map.Entry<ImprovementType, Stats> entry : typeStats.entrySet()) {
Stats stat = entry.getValue();
@@ -102,11 +101,9 @@
@Override
public String toString() {
StringBuilder sb = new StringBuilder(100);
- double pct = ((double) overallSuccesses) / ((double) overallTotals);
- sb.append("Overall Success %: ").append(pct);
for (Map.Entry<ImprovementType, Stats> entry : typeStats.entrySet()) {
Stats stat = entry.getValue();
- sb.append(" ").append(entry.getKey().name()).append(" % = ").append(stat.pct);
+ sb.append(" ").append(entry.getKey().name()).append("% = ").append(stat.pct);
}
return sb.toString();
}
@@ -118,8 +115,6 @@
for (ImprovementType type : values) {
typeStats.put(type, new Stats());
}
- overallSuccesses = 1;
- overallTotals = 1;
failureRun = 0;
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2009-11-27 19:33:03
|
Revision: 70
http://polycasso.svn.sourceforge.net/polycasso/?rev=70&view=rev
Author: dbrosius
Date: 2009-11-27 19:32:52 +0000 (Fri, 27 Nov 2009)
Log Message:
-----------
add toString
Modified Paths:
--------------
trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementTypeStats.java
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementTypeStats.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementTypeStats.java 2009-11-27 14:27:31 UTC (rev 69)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementTypeStats.java 2009-11-27 19:32:52 UTC (rev 70)
@@ -40,6 +40,8 @@
return successes + "/" + totals + " [" + pct + "]";
}
}
+ private int overallSuccesses = 1;
+ private int overallTotals = 1;
private Map<ImprovementType, Stats> typeStats = new EnumMap<ImprovementType, Stats>(ImprovementType.class);
private Random r = new Random();
@@ -60,9 +62,12 @@
*/
public void typeWasSuccessful(ImprovementType type, boolean successful) {
Stats stats = typeStats.get(type);
- if (successful)
+ if (successful) {
stats.successes++;
+ overallSuccesses++;
+ }
stats.totals++;
+ overallTotals++;
failureRun = successful ? 0 : failureRun + 1;
if (failureRun > MAX_FAILURE_RUN) {
initStats();
@@ -80,10 +85,7 @@
public ImprovementType getRandomImprovementType() {
double pct = r.nextDouble();
- double totalPct = 0.0;
- for (Stats stat : typeStats.values()) {
- totalPct += stat.pct;
- }
+ double totalPct = ((double) overallSuccesses) / ((double) overallTotals);
for (Map.Entry<ImprovementType, Stats> entry : typeStats.entrySet()) {
Stats stat = entry.getValue();
@@ -97,6 +99,17 @@
return ImprovementType.CompleteChange;
}
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder(100);
+ double pct = ((double) overallSuccesses) / ((double) overallTotals);
+ sb.append("Overall Success %: ").append(pct);
+ for (Map.Entry<ImprovementType, Stats> entry : typeStats.entrySet()) {
+ Stats stat = entry.getValue();
+ sb.append(" ").append(entry.getKey().name()).append(" % = ").append(stat.pct);
+ }
+ return sb.toString();
+ }
/**
* sets the stats to an initial state
*/
@@ -105,6 +118,8 @@
for (ImprovementType type : values) {
typeStats.put(type, new Stats());
}
+ overallSuccesses = 1;
+ overallTotals = 1;
failureRun = 0;
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2009-11-27 14:27:39
|
Revision: 69
http://polycasso.svn.sourceforge.net/polycasso/?rev=69&view=rev
Author: dbrosius
Date: 2009-11-27 14:27:31 +0000 (Fri, 27 Nov 2009)
Log Message:
-----------
calc type pct as you update success/failure
Modified Paths:
--------------
trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementTypeStats.java
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementTypeStats.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementTypeStats.java 2009-11-27 02:02:43 UTC (rev 68)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementTypeStats.java 2009-11-27 14:27:31 UTC (rev 69)
@@ -33,7 +33,7 @@
private static class Stats {
public int successes = 1;
public int totals = 1;
- public double pct = 0.0;
+ public double pct = 1.0;
@Override
public String toString() {
@@ -66,6 +66,8 @@
failureRun = successful ? 0 : failureRun + 1;
if (failureRun > MAX_FAILURE_RUN) {
initStats();
+ } else {
+ stats.pct = ((double)stats.successes) / ((double) stats.totals);
}
}
@@ -80,7 +82,6 @@
double totalPct = 0.0;
for (Stats stat : typeStats.values()) {
- stat.pct = ((double) stat.successes) / ((double) stat.totals);
totalPct += stat.pct;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2009-11-27 02:02:51
|
Revision: 68
http://polycasso.svn.sourceforge.net/polycasso/?rev=68&view=rev
Author: dbrosius
Date: 2009-11-27 02:02:43 +0000 (Fri, 27 Nov 2009)
Log Message:
-----------
on a large run of failures, reset the stats to reset the randomness of picking improvements
Modified Paths:
--------------
trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementTypeStats.java
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementTypeStats.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementTypeStats.java 2009-11-27 00:07:37 UTC (rev 67)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementTypeStats.java 2009-11-27 02:02:43 UTC (rev 68)
@@ -29,6 +29,7 @@
*/
public class ImprovementTypeStats {
+ private static final int MAX_FAILURE_RUN = 50;
private static class Stats {
public int successes = 1;
public int totals = 1;
@@ -42,6 +43,7 @@
private Map<ImprovementType, Stats> typeStats = new EnumMap<ImprovementType, Stats>(ImprovementType.class);
private Random r = new Random();
+ private int failureRun;
/**
* creates an initial state of statistics
@@ -61,6 +63,10 @@
if (successful)
stats.successes++;
stats.totals++;
+ failureRun = successful ? 0 : failureRun + 1;
+ if (failureRun > MAX_FAILURE_RUN) {
+ initStats();
+ }
}
/**
@@ -98,5 +104,6 @@
for (ImprovementType type : values) {
typeStats.put(type, new Stats());
}
+ failureRun = 0;
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2009-11-27 00:43:23
|
Revision: 67
http://polycasso.svn.sourceforge.net/polycasso/?rev=67&view=rev
Author: dbrosius
Date: 2009-11-27 00:07:37 +0000 (Fri, 27 Nov 2009)
Log Message:
-----------
if an improvement type is impossible, mark it as failed
Modified Paths:
--------------
trunk/polycasso/src/com/mebigfatguy/polycasso/Improver.java
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/Improver.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/Improver.java 2009-11-26 23:37:41 UTC (rev 66)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/Improver.java 2009-11-27 00:07:37 UTC (rev 67)
@@ -103,6 +103,7 @@
} else {
randomCompleteChange();
type = ImprovementType.CompleteChange;
+ typeWasSuccessful(ImprovementType.AddPolygon, false);
}
}
break;
@@ -136,6 +137,7 @@
} else {
randomCompleteChange();
type = ImprovementType.CompleteChange;
+ typeWasSuccessful(ImprovementType.AddPoint, false);
}
}
break;
@@ -154,6 +156,7 @@
} else {
randomCompleteChange();
type = ImprovementType.CompleteChange;
+ typeWasSuccessful(ImprovementType.RemovePoint, false);
}
}
break;
@@ -197,6 +200,7 @@
} else {
randomCompleteChange();
type = ImprovementType.CompleteChange;
+ typeWasSuccessful(ImprovementType.ReorderPoly, false);
}
}
break;
@@ -239,6 +243,22 @@
}
break;
+ case ShiftPoly: {
+ int idx = r.nextInt(polygons.size());
+ PolygonData pd = (PolygonData)polygons.get(idx).clone();
+ Polygon polygon = pd.getPolygon();
+ int shiftX = r.nextInt(2 * MAX_PT_MOVEMENT) + MAX_PT_MOVEMENT;
+ int shiftY = r.nextInt(2 * MAX_PT_MOVEMENT) + MAX_PT_MOVEMENT;
+ for (int i = 0; i < polygon.npoints; i++) {
+ polygon.xpoints[i] += shiftX;
+ polygon.ypoints[i] += shiftY;
+ polygon.xpoints[i] = clipToRange(0, imageSize.width, polygon.xpoints[i]);
+ polygon.ypoints[i] = clipToRange(0, imageSize.height, polygon.ypoints[i]);
+ }
+ polygons.set(idx, pd);
+ }
+ break;
+
case ChangeColor: {
int idx = r.nextInt(polygons.size());
PolygonData pd = (PolygonData)polygons.get(idx).clone();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2009-11-26 23:37:51
|
Revision: 66
http://polycasso.svn.sourceforge.net/polycasso/?rev=66&view=rev
Author: dbrosius
Date: 2009-11-26 23:37:41 +0000 (Thu, 26 Nov 2009)
Log Message:
-----------
add shiftpoly as an improvement type
Modified Paths:
--------------
trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementType.java
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementType.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementType.java 2009-11-26 23:12:46 UTC (rev 65)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementType.java 2009-11-26 23:37:41 UTC (rev 66)
@@ -32,6 +32,7 @@
ReorderPoly,
ShrinkPoly,
EnlargePoly,
+ ShiftPoly,
ChangeColor,
ChangeAlpha,
CompleteChange;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2009-11-26 23:12:57
|
Revision: 65
http://polycasso.svn.sourceforge.net/polycasso/?rev=65&view=rev
Author: dbrosius
Date: 2009-11-26 23:12:46 +0000 (Thu, 26 Nov 2009)
Log Message:
-----------
make addpoint add the point in the bounding box between the point before, and the point after the insertion point.
Modified Paths:
--------------
trunk/polycasso/src/com/mebigfatguy/polycasso/Improver.java
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/Improver.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/Improver.java 2009-11-26 22:59:49 UTC (rev 64)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/Improver.java 2009-11-26 23:12:46 UTC (rev 65)
@@ -34,6 +34,7 @@
*/
public class Improver {
public static final int NUM_POLYS = 50;
+ public static final int MAX_PT_MOVEMENT = 20;
private Dimension imageSize;
private List<PolygonData> polygons = null;
@@ -119,9 +120,13 @@
if (polygon.npoints <= PolygonData.MAX_POINTS) {
polygon.addPoint(0, 0);
int insPos = r.nextInt(polygon.npoints);
- int x = r.nextInt(imageSize.width);
- int y = r.nextInt(imageSize.height);
+ int lastPt = (insPos + polygon.npoints - 1) % polygon.npoints;
+ int maxX = Math.max(MAX_PT_MOVEMENT, Math.abs(polygon.xpoints[lastPt] - polygon.xpoints[insPos]));
+ int maxY = Math.max(MAX_PT_MOVEMENT, Math.abs(polygon.ypoints[lastPt] - polygon.ypoints[insPos]));
+ int x = r.nextInt(maxX) + Math.min(polygon.xpoints[lastPt], polygon.xpoints[insPos]);
+ int y = r.nextInt(maxY) + Math.min(polygon.ypoints[lastPt], polygon.ypoints[insPos]);
+
System.arraycopy(polygon.xpoints, insPos, polygon.xpoints, insPos + 1, polygon.npoints - insPos - 1);
polygon.xpoints[insPos] = x;
System.arraycopy(polygon.ypoints, insPos, polygon.ypoints, insPos + 1, polygon.npoints - insPos - 1);
@@ -158,8 +163,8 @@
PolygonData pd = (PolygonData)polygons.get(idx).clone();
Polygon polygon = pd.getPolygon();
int movePos = r.nextInt(polygon.npoints);
- int moveX = r.nextInt(20) - 10;
- int moveY = r.nextInt(20) - 10;
+ int moveX = r.nextInt(MAX_PT_MOVEMENT * 2) - MAX_PT_MOVEMENT;
+ int moveY = r.nextInt(MAX_PT_MOVEMENT * 2) - MAX_PT_MOVEMENT;
polygon.xpoints[movePos] += moveX;
polygon.ypoints[movePos] += moveY;
clipToRange(0, imageSize.width, polygon.xpoints[movePos]);
@@ -205,7 +210,7 @@
double midX = bbox.getCenterX();
double midY = bbox.getCenterY();
- int shrinkFactor = r.nextInt(5);
+ int shrinkFactor = r.nextInt(MAX_PT_MOVEMENT);
for (int i = 0; i < polygon.npoints; i++) {
polygon.xpoints[i] += (polygon.xpoints[i] < midX) ? shrinkFactor : -shrinkFactor;
polygon.ypoints[i] += (polygon.ypoints[i] < midY) ? shrinkFactor : -shrinkFactor;
@@ -223,7 +228,7 @@
double midX = bbox.getCenterX();
double midY = bbox.getCenterY();
- int expandFactor = r.nextInt(5);
+ int expandFactor = r.nextInt(MAX_PT_MOVEMENT);
for (int i = 0; i < polygon.npoints; i++) {
polygon.xpoints[i] += (polygon.xpoints[i] < midX) ? -expandFactor : expandFactor;
polygon.ypoints[i] += (polygon.ypoints[i] < midY) ? -expandFactor : expandFactor;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2009-11-26 22:59:55
|
Revision: 64
http://polycasso.svn.sourceforge.net/polycasso/?rev=64&view=rev
Author: dbrosius
Date: 2009-11-26 22:59:49 +0000 (Thu, 26 Nov 2009)
Log Message:
-----------
have one more generator than processors
Modified Paths:
--------------
trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java 2009-11-26 22:59:08 UTC (rev 63)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java 2009-11-26 22:59:49 UTC (rev 64)
@@ -100,7 +100,7 @@
synchronized(startStopLock) {
attempt = 0;
if (t == null) {
- t = new Thread[Runtime.getRuntime().availableProcessors()];
+ t = new Thread[Runtime.getRuntime().availableProcessors() + 1];
for (int i = 0; i < t.length; i++) {
t[i] = new Thread(this);
t[i].start();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2009-11-26 22:59:15
|
Revision: 63
http://polycasso.svn.sourceforge.net/polycasso/?rev=63&view=rev
Author: dbrosius
Date: 2009-11-26 22:59:08 +0000 (Thu, 26 Nov 2009)
Log Message:
-----------
reset attempts on start
Modified Paths:
--------------
trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java 2009-11-26 06:52:52 UTC (rev 62)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java 2009-11-26 22:59:08 UTC (rev 63)
@@ -98,6 +98,7 @@
*/
public void startGenerating() {
synchronized(startStopLock) {
+ attempt = 0;
if (t == null) {
t = new Thread[Runtime.getRuntime().availableProcessors()];
for (int i = 0; i < t.length; i++) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2009-11-26 06:53:00
|
Revision: 62
http://polycasso.svn.sourceforge.net/polycasso/?rev=62&view=rev
Author: dbrosius
Date: 2009-11-26 06:52:52 +0000 (Thu, 26 Nov 2009)
Log Message:
-----------
javadoc
Modified Paths:
--------------
trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementTypeStats.java
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementTypeStats.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementTypeStats.java 2009-11-26 06:32:17 UTC (rev 61)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementTypeStats.java 2009-11-26 06:52:52 UTC (rev 62)
@@ -67,7 +67,7 @@
* returns a random improvement type that is influenced by how successful the types
* have been in the past.
*
- * @returns the improvement type to try
+ * @return the improvement type to try
*/
public ImprovementType getRandomImprovementType() {
double pct = r.nextDouble();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2009-11-26 06:32:25
|
Revision: 61
http://polycasso.svn.sourceforge.net/polycasso/?rev=61&view=rev
Author: dbrosius
Date: 2009-11-26 06:32:17 +0000 (Thu, 26 Nov 2009)
Log Message:
-----------
improver type back to being just an enum. The ImproverTypeStats class is now responsible for finding a new type to try
Modified Paths:
--------------
trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementType.java
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementType.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementType.java 2009-11-26 06:31:39 UTC (rev 60)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementType.java 2009-11-26 06:32:17 UTC (rev 61)
@@ -35,14 +35,4 @@
ChangeColor,
ChangeAlpha,
CompleteChange;
-
- /**
- * returns a improvement type at random to try on an image
- *
- * @return an improvement type
- */
- public static ImprovementType getRandomImprovement() {
- ImprovementType[] types = ImprovementType.values();
- return types[(int)((int)(Math.random() * types.length))];
- }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2009-11-26 06:31:49
|
Revision: 60
http://polycasso.svn.sourceforge.net/polycasso/?rev=60&view=rev
Author: dbrosius
Date: 2009-11-26 06:31:39 +0000 (Thu, 26 Nov 2009)
Log Message:
-----------
accomodate the improver stats
Modified Paths:
--------------
trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java 2009-11-26 06:31:08 UTC (rev 59)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java 2009-11-26 06:31:39 UTC (rev 60)
@@ -182,6 +182,7 @@
image = new BufferedImage(imageSize.width, imageSize.height, BufferedImage.TYPE_4BYTE_ABGR);
g2d = (Graphics2D)image.getGraphics();
}
+ improver.typeWasSuccessful(type, newBest);
}
} catch (Exception e) {
e.printStackTrace();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2009-11-26 06:31:22
|
Revision: 59
http://polycasso.svn.sourceforge.net/polycasso/?rev=59&view=rev
Author: dbrosius
Date: 2009-11-26 06:31:08 +0000 (Thu, 26 Nov 2009)
Log Message:
-----------
a class to maintain success/failure statistics per improvement type, so that 'random' selection of new improvement types can increase the probability of success, by favoring types that are higher successes
also make MovePoint more controlled so to be more effective
Modified Paths:
--------------
trunk/polycasso/src/com/mebigfatguy/polycasso/Improver.java
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/Improver.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/Improver.java 2009-11-26 06:30:31 UTC (rev 58)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/Improver.java 2009-11-26 06:31:08 UTC (rev 59)
@@ -37,6 +37,7 @@
private Dimension imageSize;
private List<PolygonData> polygons = null;
+ private ImprovementTypeStats stats;
private Random r;
/**
@@ -46,6 +47,7 @@
*/
public Improver(Dimension size) {
imageSize = size;
+ stats = new ImprovementTypeStats();
r = new Random();
}
@@ -68,6 +70,16 @@
}
/**
+ * updates the stats for types that successfully improved the image
+ *
+ * @param type the improvement type that was successful
+ * @param successful whether the improvement was successful
+ */
+ public void typeWasSuccessful(ImprovementType type, boolean successful) {
+ stats.typeWasSuccessful(type, successful);
+ }
+
+ /**
* attempts to improve on one polygon randomly by adjusting it according to a randomly
* selected improvement type
*
@@ -80,7 +92,7 @@
return ImprovementType.AddPolygon;
}
- ImprovementType type = ImprovementType.getRandomImprovement();
+ ImprovementType type = stats.getRandomImprovementType();
switch (type) {
case AddPolygon: {
@@ -146,8 +158,12 @@
PolygonData pd = (PolygonData)polygons.get(idx).clone();
Polygon polygon = pd.getPolygon();
int movePos = r.nextInt(polygon.npoints);
- polygon.xpoints[movePos] = r.nextInt(imageSize.width);
- polygon.ypoints[movePos] = r.nextInt(imageSize.height);
+ int moveX = r.nextInt(20) - 10;
+ int moveY = r.nextInt(20) - 10;
+ polygon.xpoints[movePos] += moveX;
+ polygon.ypoints[movePos] += moveY;
+ clipToRange(0, imageSize.width, polygon.xpoints[movePos]);
+ clipToRange(0, imageSize.height, polygon.ypoints[movePos]);
polygons.set(idx, pd);
}
break;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2009-11-26 06:30:43
|
Revision: 58
http://polycasso.svn.sourceforge.net/polycasso/?rev=58&view=rev
Author: dbrosius
Date: 2009-11-26 06:30:31 +0000 (Thu, 26 Nov 2009)
Log Message:
-----------
a class to maintain success/failure statistics per improvement type, so that 'random' selection of new improvement types can increase the probability of success, by favoring types that are higher successes
Added Paths:
-----------
trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementTypeStats.java
Added: trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementTypeStats.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementTypeStats.java (rev 0)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementTypeStats.java 2009-11-26 06:30:31 UTC (rev 58)
@@ -0,0 +1,102 @@
+/*
+ * polycasso - Cubism Artwork generator
+ * Copyright 2009 MeBigFatGuy.com
+ * Copyright 2009 Dave Brosius
+ * Inspired by work by Roger Alsing
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and limitations
+ * under the License.
+ */
+package com.mebigfatguy.polycasso;
+
+import java.util.EnumMap;
+import java.util.Map;
+import java.util.Random;
+
+/**
+ * a class to keep track of success statistics by improvement type, in order to further tune what
+ * improvement types to try in the future. It modifies a purely random selection criteria to one that
+ * is tuned by performance.
+ */
+public class ImprovementTypeStats {
+
+ private static class Stats {
+ public int successes = 1;
+ public int totals = 1;
+ public double pct = 0.0;
+
+ @Override
+ public String toString() {
+ return successes + "/" + totals + " [" + pct + "]";
+ }
+ }
+
+ private Map<ImprovementType, Stats> typeStats = new EnumMap<ImprovementType, Stats>(ImprovementType.class);
+ private Random r = new Random();
+
+ /**
+ * creates an initial state of statistics
+ */
+ public ImprovementTypeStats() {
+ initStats();
+ }
+
+ /**
+ * increment a type's statistics whether success or fail
+ *
+ * @param type the improvement type that is to be updated
+ * @param successful if the improvement was successful
+ */
+ public void typeWasSuccessful(ImprovementType type, boolean successful) {
+ Stats stats = typeStats.get(type);
+ if (successful)
+ stats.successes++;
+ stats.totals++;
+ }
+
+ /**
+ * returns a random improvement type that is influenced by how successful the types
+ * have been in the past.
+ *
+ * @returns the improvement type to try
+ */
+ public ImprovementType getRandomImprovementType() {
+ double pct = r.nextDouble();
+
+ double totalPct = 0.0;
+ for (Stats stat : typeStats.values()) {
+ stat.pct = ((double) stat.successes) / ((double) stat.totals);
+ totalPct += stat.pct;
+ }
+
+ for (Map.Entry<ImprovementType, Stats> entry : typeStats.entrySet()) {
+ Stats stat = entry.getValue();
+ double typePct = stat.pct / totalPct;
+ if (pct <= typePct)
+ return entry.getKey();
+
+ pct -= typePct;
+ }
+
+ return ImprovementType.CompleteChange;
+ }
+
+ /**
+ * sets the stats to an initial state
+ */
+ private void initStats() {
+ ImprovementType[] values = ImprovementType.values();
+ for (ImprovementType type : values) {
+ typeStats.put(type, new Stats());
+ }
+ }
+}
Property changes on: trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementTypeStats.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2009-11-26 04:13:31
|
Revision: 57
http://polycasso.svn.sourceforge.net/polycasso/?rev=57&view=rev
Author: dbrosius
Date: 2009-11-26 04:13:20 +0000 (Thu, 26 Nov 2009)
Log Message:
-----------
no longer immutable
Modified Paths:
--------------
trunk/polycasso/src/com/mebigfatguy/polycasso/PolygonData.java
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/PolygonData.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/PolygonData.java 2009-11-26 01:55:18 UTC (rev 56)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/PolygonData.java 2009-11-26 04:13:20 UTC (rev 57)
@@ -26,7 +26,7 @@
import java.util.Random;
/**
- * an immutable class for holding the information for one polygon, including points, color
+ * a class for holding the information for one polygon, including points, color
* and alpha level.
*/
public class PolygonData implements Cloneable {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2009-11-26 01:55:33
|
Revision: 56
http://polycasso.svn.sourceforge.net/polycasso/?rev=56&view=rev
Author: dbrosius
Date: 2009-11-26 01:55:18 +0000 (Thu, 26 Nov 2009)
Log Message:
-----------
base number of improvers on Runtime.getRuntime().availableProcessors()
Modified Paths:
--------------
trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java 2009-11-25 15:05:30 UTC (rev 55)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java 2009-11-26 01:55:18 UTC (rev 56)
@@ -36,9 +36,6 @@
* This class generates multiple images in parallel to keep multicore processors busy.
*/
public class ImageGenerator implements Runnable {
- private static final int NUM_THREADS = 8;
-
-
private static int attempt = 0;
private Set<ImageGeneratedListener> listeners = new HashSet<ImageGeneratedListener>();
private PolygonData[] bestData;
@@ -102,8 +99,8 @@
public void startGenerating() {
synchronized(startStopLock) {
if (t == null) {
- t = new Thread[NUM_THREADS];
- for (int i = 0; i < NUM_THREADS; i++) {
+ t = new Thread[Runtime.getRuntime().availableProcessors()];
+ for (int i = 0; i < t.length; i++) {
t[i] = new Thread(this);
t[i].start();
}
@@ -118,10 +115,10 @@
synchronized(startStopLock) {
if (t != null) {
try {
- for (int i = 0; i < NUM_THREADS; i++) {
+ for (int i = 0; i < t.length; i++) {
t[i].interrupt();
}
- for (int i = 0; i < NUM_THREADS; i++) {
+ for (int i = 0; i < t.length; i++) {
t[i].join();
}
} catch (InterruptedException ie) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2009-11-25 15:05:39
|
Revision: 55
http://polycasso.svn.sourceforge.net/polycasso/?rev=55&view=rev
Author: dbrosius
Date: 2009-11-25 15:05:30 +0000 (Wed, 25 Nov 2009)
Log Message:
-----------
Modified Paths:
--------------
trunk/polycasso/htdocs/index.html
Modified: trunk/polycasso/htdocs/index.html
===================================================================
--- trunk/polycasso/htdocs/index.html 2009-11-25 15:03:58 UTC (rev 54)
+++ trunk/polycasso/htdocs/index.html 2009-11-25 15:05:30 UTC (rev 55)
@@ -24,6 +24,8 @@
<p>Launch the application, choose 'Start Generating Image', and let it sit for several hours, even a day.
Good artwork takes time! -- and so does this.</p>
+
+ <p>-- Dave Brosius</p>
</div>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2009-11-25 15:04:08
|
Revision: 54
http://polycasso.svn.sourceforge.net/polycasso/?rev=54&view=rev
Author: dbrosius
Date: 2009-11-25 15:03:58 +0000 (Wed, 25 Nov 2009)
Log Message:
-----------
sample
Added Paths:
-----------
trunk/polycasso/htdocs/images/
trunk/polycasso/htdocs/images/polyplane.png
Added: trunk/polycasso/htdocs/images/polyplane.png
===================================================================
(Binary files differ)
Property changes on: trunk/polycasso/htdocs/images/polyplane.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2009-11-25 06:36:18
|
Revision: 53
http://polycasso.svn.sourceforge.net/polycasso/?rev=53&view=rev
Author: dbrosius
Date: 2009-11-25 06:35:46 +0000 (Wed, 25 Nov 2009)
Log Message:
-----------
add RectifyPoint
Modified Paths:
--------------
trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementType.java
trunk/polycasso/src/com/mebigfatguy/polycasso/Improver.java
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementType.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementType.java 2009-11-25 05:56:12 UTC (rev 52)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementType.java 2009-11-25 06:35:46 UTC (rev 53)
@@ -27,7 +27,8 @@
RemovePolygon,
AddPoint,
RemovePoint,
- MovePoint,
+ MovePoint,
+ RectifyPoint,
ReorderPoly,
ShrinkPoly,
EnlargePoly,
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/Improver.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/Improver.java 2009-11-25 05:56:12 UTC (rev 52)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/Improver.java 2009-11-25 06:35:46 UTC (rev 53)
@@ -152,6 +152,23 @@
}
break;
+ case RectifyPoint: {
+ int idx = r.nextInt(polygons.size());
+ PolygonData pd = (PolygonData)polygons.get(idx).clone();
+ Polygon polygon = pd.getPolygon();
+ int rectifyPos = r.nextInt(polygon.npoints);
+ int targetPos = (rectifyPos == 0) ? polygon.npoints - 1 : (rectifyPos - 1);
+
+ if (Math.abs(polygon.xpoints[rectifyPos] - polygon.xpoints[targetPos]) <
+ Math.abs(polygon.ypoints[rectifyPos] - polygon.ypoints[targetPos])) {
+ polygon.xpoints[rectifyPos] = polygon.xpoints[targetPos];
+ } else {
+ polygon.ypoints[rectifyPos] = polygon.ypoints[targetPos];
+ }
+ polygons.set(idx, pd);
+ }
+ break;
+
case ReorderPoly: {
if (polygons.size() > 2) {
PolygonData pd = polygons.remove(r.nextInt(polygons.size()));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2009-11-25 05:56:23
|
Revision: 52
http://polycasso.svn.sourceforge.net/polycasso/?rev=52&view=rev
Author: dbrosius
Date: 2009-11-25 05:56:12 +0000 (Wed, 25 Nov 2009)
Log Message:
-----------
attempt to look for an image 5 times, in case of transient failures
Modified Paths:
--------------
trunk/polycasso/src/com/mebigfatguy/polycasso/RandomImageFinder.java
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/RandomImageFinder.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/RandomImageFinder.java 2009-11-25 05:42:04 UTC (rev 51)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/RandomImageFinder.java 2009-11-25 05:56:12 UTC (rev 52)
@@ -47,6 +47,7 @@
private static final Pattern IMAGE_HTML_PATTERN = Pattern.compile("<div\\s+class=\"imageResult\"><a\\s+href=\"([^\"]*)\"");
private static final Pattern IMAGE_PATTERN = Pattern.compile("image_url=([^&]*)&");
private static final int NAMELEN = 3;
+ private static final int ATTEMPTS = 5;
/**
* private to avoid construction of this static access only class
@@ -63,14 +64,33 @@
*/
public static Image findImage() throws IOException {
- char[] ranName = new char[NAMELEN];
- Random ran = new Random(System.currentTimeMillis());
- for (int i = 0; i < NAMELEN; i++) {
- ranName[i] = (char)('A' + ran.nextInt(26));
+ for (int i = 0; i < ATTEMPTS; i++) {
+ try {
+ char[] ranName = new char[NAMELEN];
+ Random ran = new Random(System.currentTimeMillis());
+ for (int c = 0; c < NAMELEN; c++) {
+ ranName[c] = (char)('A' + ran.nextInt(26));
+ }
+
+ return findImageAt(MessageFormat.format(URL, new String(ranName)));
+ } catch (IOException ioe) {
+ }
}
- String html = new String(getUrlData(MessageFormat.format(URL, new String(ranName))), "UTF-8");
+ throw new IOException("Failed to find an inspiration to draw");
+ }
+
+ /**
+ * retrieve an image thru lycos image search
+ *
+ * @param url the url to look for the image
+ * @return the image
+ * @throws IOException if the site that is hosting the image is down, or non responsive
+ */
+ private static final Image findImageAt(String url) throws IOException {
+ String html = new String(getUrlData(url), "UTF-8");
+
List<String> images = new ArrayList<String>();
Matcher m = IMAGE_HTML_PATTERN.matcher(html);
@@ -82,9 +102,9 @@
m = IMAGE_PATTERN.matcher(html);
if (m.find()) {
- String url = URLDecoder.decode(m.group(1), "UTF-8");
+ String imageUrl = URLDecoder.decode(m.group(1), "UTF-8");
- return new ImageIcon(getUrlData(url)).getImage();
+ return new ImageIcon(getUrlData(imageUrl)).getImage();
}
throw new IOException("Failed to find image");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2009-11-25 05:42:14
|
Revision: 51
http://polycasso.svn.sourceforge.net/polycasso/?rev=51&view=rev
Author: dbrosius
Date: 2009-11-25 05:42:04 +0000 (Wed, 25 Nov 2009)
Log Message:
-----------
javadoc
Modified Paths:
--------------
trunk/polycasso/src/com/mebigfatguy/polycasso/RandomImageFinder.java
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/RandomImageFinder.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/RandomImageFinder.java 2009-11-25 04:22:39 UTC (rev 50)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/RandomImageFinder.java 2009-11-25 05:42:04 UTC (rev 51)
@@ -37,6 +37,9 @@
import org.apache.commons.io.IOUtils;
+/**
+ * finds an image on the web to try to draw with polygons
+ */
public class RandomImageFinder {
private static final String ROOTURL = "http://search.lycos.com/";
@@ -45,9 +48,19 @@
private static final Pattern IMAGE_PATTERN = Pattern.compile("image_url=([^&]*)&");
private static final int NAMELEN = 3;
+ /**
+ * private to avoid construction of this static access only class
+ */
private RandomImageFinder() {
}
-
+
+ /**
+ * finds an image thru lycos image search
+ *
+ * @return a random image
+ *
+ * @throws IOException if fetching resources at urls fails
+ */
public static Image findImage() throws IOException {
char[] ranName = new char[NAMELEN];
@@ -77,6 +90,14 @@
throw new IOException("Failed to find image");
}
+ /**
+ * retrieve arbitrary data found at a specific url
+ *
+ * @param url the url to retrieve
+ * @return a byte array of the content
+ *
+ * @throws IOException the site fails to respond
+ */
private static byte[] getUrlData(String url) throws IOException {
HttpURLConnection con = null;
InputStream is = null;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|