zomis / fighting Goto Github PK
View Code? Open in Web Editor NEWExtracting statistics since 2013
Extracting statistics since 2013
It might be useful in #3 to export the entire logs of all objects that was posted to the extractor
Related to #11. Add support for one object being able to create multiple indexes.
Something like:
public static class IndexExample {
Function<String, char[]> endingChar = str -> new char[]{ str.charAt(0), str.charAt(str.length() - 1) };
ToIntFunction<String> length = str -> str.length();
}
Extractor extractor = Extractor.extractor(new IndexExample());
extractor.postPrimary().post("teat");
extractor.postPrimary().post("af");
IndexableResults results = extractor.collectIndexable();
data = results.indexBy("endingChar");
data
should now contain something like:
endingChar=a : { size = 2 }
endingChar=f : { size = 2 }
endingChar=t : { size = 4 + 4 }
Note that because teat
both begins and ends with 't', that data is added twice to that index.
At the moment all collectors and functions and stuff needs to be declared in a class. This is a big limitation for a more dynamic usage of the extraction.
Make it possible to dynamically add functions and collectors to the class
Something like:
Extractor extractor = new Extractor();
extractor.add(ToIntFunction.class, String.class, str -> str.length());
Using the JavaScript library 'flot', it can be possible to add support for graphs
Add README with information about what's possible with this library, and how to do it.
This would benefit greatly from Kotlin flows.
However, I would wonder if there's a risk that this project might become "too abstract" and not provide any real value? This is something to look out for here.
Let's say that you have classes A
and B
, where B extends A
:
class A {
public int getValue() {
return 42;
}
}
class B extends A { }
And the following extract setup:
public class Extract {
ToIntFunction<A> someValue = a -> a.getValue();
}
Extractor extractor = Extractor.create(new Extract());
It should now be possible to post an object of class B
and also inform the ToIntFunction
that uses A
.
extractor.post(new B());
After a run, it should be possible to export the retrieved data to HTML
Related to #1. Instead of calling .post
directly, it should also be possible to add event listeners for more complicated situations, so that you can listen for an event and post that to the extractor.
Would be useful for Cardshifter/Cardshifter#121, with for example Function<ActionPerformEvent, String>
It should be possible to index results acquired from #1 in a neat way, for example like the current, "new", style:
Fights
Data: {WinnerCastle=17.683333333333334, Wins=120: 0/120/0 (50.00 %)}
Player CWars2AI_InstantWin:
Data: {WinnerCastle=16.375, Wins=60: 40/0/20 (66.67 %)}
Opponent CWars2AI_Better:
Data: {WinnerCastle=17.9, Wins=20: 10/0/10 (50.00 %)}
In #3, it would be nice to have an ability to show/hide various statistics. Perhaps you are only interested to see the total damage dealt and not the average number of resources used per turn.
Also applies to possible sub-stats, for example on a Map<Resource, IntSummaryStatistics>
, add a checkbox on each Resource
.
Let's say there's a big huge collecting class:
public static class Example {
ToIntFunction<String> length = str -> str.length();
ToIntFunction<String> numA = str -> (int) str.chars().filter(ch -> ch == 97).count();
ToIntFunction<Character> charValue = ch -> ch.charValue();
...
}
And you don't want to collect all of those fields, then use a skip
method to clear those.
Extractor extractor = Extractor.extractor(new IndexExample());
extractor.skip("numA");
Alternatively, use the inheritance from #9 and use @IgnoreStat
annotations or similar
As a way of filtering what data is collected, add a @Predicate
annotation with a reference to a field with a predicate, to determine whether or not to collect the data.
Predicate<String> pred = s -> s.length() > 10;
@Predicate("pred")
ToIntFunction<String> len = s -> s.length();
In this case, len
will only consider strings with more than 10 length.
It should be possible to group statistics into various indexes.
For example:
public static class IndexExample {
Function<String, Integer> sizeIndex = str -> str.length();
Function<String, Character> firstLetter = str -> str.charAt(0);
ToIntFunction<String> length = str -> str.length();
ToIntFunction<String> numA = str -> (int) str.chars().filter(ch -> ch == 97).count();
}
And the code/data:
Extractor extractor = Extractor.extractor(new IndexExample());
extractor.post("teat");
extractor.post("a_a_");
extractor.post("tca");
extractor.post("abc");
extractor.post("aaa");
This should produce something like:
Unindexed: { length = 4+4+3+3+3, numA = 1+2+1+1+3 }
size=3: { length = 3+3+3, numA = 1+1+3 }
size=4: { length = 4+4, numA = 1+2 }
firstLetter=t: { length = 4+3, numA = 1+1 }
firstLetter=a: { length = 4+3+3, numA = 2+1+3 }
size=3,firstLetter=a: { length = 3+3, numA = 1+3 }
size=3,firstLetter=t: { length = 3, numA = 1 }
size=4,firstLetter=a: { length = 4, numA = 2 }
size=4,firstLetter=t: { length = 4, numA = 1 }
Because of the enormous amount of combinations, and to support #6, all the data for all the index should probably be stored, and then filters and indexes can be applied on the raw data. Possibly use JSON as format for the raw data.
#5 is about exporting to HTML, this is different as it is about supporting it in the core.
Example code:
public class Example {
ToIntFunction<String> length = str -> str.length();
ToIntFunction<String> numberOfAs = str -> str.chars().filter(ch -> ch == 65).count();
}
This would then be collected in a result as a IntSummaryStatistics
(Java 8 has a collector for this).
Code to do the collecting:
Extractor extract = new Extractor();
extract.post("test");
extract.post("Hello World");
extract.post("yet another message");
ExtractorResults results = extract.collect();
In most cases it should be possible to run fights in multiple threads.
Consider this:
public static class Example {
ToIntFunction<String> length = str -> str.length();
ToIntFunction<Character> charValue = ch -> ch.charValue();
}
public static class IndexExample extends Example {
ToIntFunction<String> numA = str -> (int) str.chars().filter(ch -> ch == 97).count();
}
It should be possible to perform extraction with SecondExample
and include all the things from Example
.
If naming collisions occur, either throw an exception, or solve collisions by prepending the class name, such as IndexExample::something
and Example::something
(but then there's the possibility of two classes with the same name in separate packages, sigh... okay, exception it is!)
It would be nice to collect information about what rating for players would be after a series of games has been played.
The bad thing about this is that it is dependent on the order of the games.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.