Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Color parameter outside of expected range: Green #12

Open
Bitals opened this issue Apr 26, 2023 · 4 comments
Open

Color parameter outside of expected range: Green #12

Bitals opened this issue Apr 26, 2023 · 4 comments

Comments

@Bitals
Copy link

Bitals commented Apr 26, 2023

I left it running for some time, it hanged with the following error:

Exception in thread "main" java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: Color parameter outside of expected range: Green
	at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:67)
	at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:484)
	at java.base/java.util.concurrent.ForkJoinTask.getThrowableException(ForkJoinTask.java:540)
	at java.base/java.util.concurrent.ForkJoinTask.reportException(ForkJoinTask.java:567)
	at java.base/java.util.concurrent.ForkJoinTask.invoke(ForkJoinTask.java:670)
	at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateParallel(ForEachOps.java:159)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateParallel(ForEachOps.java:173)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:233)
	at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
	at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:765)
	at protoevo.env.Tank.update(Tank.java:200)
	at protoevo.core.Simulation.update(Simulation.java:220)
	at protoevo.core.Simulation.simulate(Simulation.java:187)
	at protoevo.core.Application.run(Application.java:53)
	at protoevo.core.Application.main(Application.java:32)
Caused by: java.lang.IllegalArgumentException: Color parameter outside of expected range: Green
	at java.desktop/java.awt.Color.testColorValueRange(Color.java:312)
	at java.desktop/java.awt.Color.<init>(Color.java:397)
	at java.desktop/java.awt.Color.<init>(Color.java:371)
	at protoevo.biology.Cell.getColor(Cell.java:438)
	at protoevo.biology.Protozoan.see(Protozoan.java:177)
	at protoevo.biology.Protozoan.interact(Protozoan.java:254)
	at protoevo.biology.Protozoan.lambda$handleInteractions$0(Protozoan.java:325)
	at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
	at protoevo.biology.Protozoan.handleInteractions(Protozoan.java:325)
	at protoevo.env.Tank.updateCell(Tank.java:171)
	at protoevo.env.Tank.lambda$update$5(Tank.java:200)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
	at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
	at java.base/java.util.stream.ForEachOps$ForEachTask.compute(ForEachOps.java:290)
	at java.base/java.util.concurrent.CountedCompleter.exec(CountedCompleter.java:754)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1312)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1843)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1808)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:188)

image
image

@David-Hari
Copy link

I had the same problem. Not sure how it can happen, the code seems to be constructing a Color object from red, green and blue components, not a string name like "Green".

@micutio
Copy link

micutio commented Aug 15, 2023

Per the stack trace it originates in Cell.getColor(). The green value calculated from the cell health is outside of the range [0,255]. Maybe it's a dead cell or the health is otherwise outside of the normal range.

Is there a configuration that makes the issue reproducible every time it's run?

@Bitals
Copy link
Author

Bitals commented Aug 16, 2023

Is there a configuration that makes the issue reproducible every time it's run?

Every time it happened it did so after a long time (overnight for example), so unfortunately I do not have a save close enough to be useful.

@David-Hari
Copy link

David-Hari commented Aug 17, 2023

It does not always happen and I don't know how to reproduce (it could happen to any of the thousands of cells that exist in the simulation).
But if it's just a matter of the green component being outside the range then the solution would be as simple as clamping the red, green and blue values to [0, 255]. I mean, it doesn't really matter if the colour of a cell is "too" green unless that colour is not just for display but is also somehow being used in the calculations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants