Open Side Menu Go to the Top
Register
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

04-09-2018 , 07:46 PM
Quote:
Originally Posted by Grue
Well its open sourced anyways so technically they could take it and do whatever with it but obviously they're meatspace people. IDK.. good problems to have I guess.
Yeah, if its all open source I guess there's not much value in selling it. Since the value of your site is all in you knowing how to actually run and operate it.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-09-2018 , 08:58 PM
and the playerbase who I assume will follow me to something similar when I get around to making it. Have a couple ideas but people keep giving me more to do on this ugh. 145 open issues.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-09-2018 , 11:18 PM
Playing poker, would like to configure and play HU NL against DeepStack, and also use the same Deep Learning algorithm for limit hold'em and mixed poker.

https://www.deepstack.ai/

If anyone else is interested in playing DeepStack HU, PM me. The programming languages are Ruby (for the GUI), C, Lua, and Torch as well as some basic scripting. It takes full advantage of Deep Learning algorithms. Dustin Morrill's code is excellent, but it's not so easy to decipher. The algorithm is limited to HU because of mathematical reasons that I don't fully understand.

Side note: There's a new book from the University of Alberta on reinforcement learning. It's in it's final draft. It's a little beyond my comprehension, but fascinating stuff. Self-driving cars here we come.

https://drive.google.com/file/d/1xeU...j2C7aAFWY/view

I am planning on taking computer science courses, finishing my two-year, find a deep learning college, and perhaps go into the AI field for contract work. Playing against model poker is ideal for poker lessons.

Last edited by leavesofliberty; 04-09-2018 at 11:30 PM.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-12-2018 , 09:16 PM
I don't have much time, but I'm interested in this, and have been getting into deep learning.

From the deepstack.ai site, it looks like they've released the code for leduc poker, but not their HUNL code. Were you planning on taking the leduc code and extrapolating it to reproduce their HUNL work? Would be an interesting project, but very challenging I'd imagine.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-12-2018 , 11:49 PM
I don't want to do a code upheaval. I believe it's possible to do the DeepStack algorithm by changing some configuration files, and train DeepStack on HUNL instead. It's only configured for Leduc. It would, however, take significant code changes to alter DeepStack to do limit poker, or mixed games poker, because that would take more than just configuration. So, I want to get the most poker knowledge for the least time, so the project I am thinking is playing the bot heads-up and OpenSource an analysis tool so you can do post-game analysis.

I'm either going to work on this or find something in RL, because I see self-driving cars and robots making decisions. Automakers are going to make Rosie. I should perhaps find something related to that.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-14-2018 , 12:27 PM
got a code golf problem for you guys

term frequency counter, where we want the top 25 terms in a text file, with a list of stop words to not include. the text file is read from command line and stop words are contained in a .txt file as well

can't use python, c++, ruby, scala, or clojure

I have a pretty hilarious java solution.

shield your eyes (graded on # of chars, I got ~1100 which is pretty decent i think)

the readable solution was ~20ish lines

Spoiler:
Code:
import java.io*;import java.util.*;public class FrequencyCounter61{public class Word implements Comparable<Word>
{public String wo;public int fr;public Word(){}public Word(String s, int f){wo=s;fr=f;}
public int compareTo(Word w){if(this.fr>w.fr)return-1;else if(this.fr==w.fr)return 0;
else return 1;}}public static ArrayList<String> pi(Scanner i, ArrayList<String> s){ArrayList<String> o=new ArrayList<String>();
i.useDelimiter("[^A-Za-z]+");while(i.hasNext()){String w=i.next().toLowerCase();if(!s.contains(w)&&w.length()>1)o.add(w);}return o;}
public static void main(String[] args) throws FileNotFoundException{ArrayList<String> p=pi(new Scanner(new File(args[0])),
pi(new Scanner(new File("stop_words.txt")),new ArrayList<String>()));FrequencyCounter61 fq=new FrequencyCounter61();
ArrayList<Word> t=new ArrayList<Word>();int count = 0;String s;while(p.size()>0){s=p.get(0);
while (p.remove(s)) count++;t.add(fq.new Word(s, count));count=0;}Collections.sort(t);
for(int i=0;i<25;i++){System.out.println(t.get(i).wo + " - " + t.get(i).fr);}}}

Last edited by jmakin; 04-14-2018 at 12:35 PM. Reason: realized i can remove a bunch of imports
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-14-2018 , 06:34 PM
Am I JavaScripting correctly? Without being a full solution (assumes input is passed rather than adding a couple lines to read the files), this is (kind of) a one line solution and is 296 chars not including the added-for-readability comments: (also I didn't actually try running it so something's prob broken)

Spoiler:
Code:
// input = string, stops = array of words to ignore
let f = (input, stops) =>
	// get array of [word, count] entries for each non-ignored word in input
	Object.entries(
		// split the input string on whitespace
		input.split(/\s+/)

		// remove all words that should be ignored
		.filter(word => !stops.includes(word))

		// create a dictionary of word => # of times it appears
		.reduce((dict, word) => {
			if (!dict[word]) dict[word] = 1;
			else dict[word]++;
			return dict;
		}, {})

	// sort this array of [word, count] entries by word count
	).sort((a, b) => b[1] - a[1])

		// grab the top 25
		.slice(0, 25)

		// grab only the word from the array (get rid of the count)
		.map(kv => kv[0])

		// make into a newline-delimited string
		.join('\n')


There's probably a 1 line way to do the code inside the reduce(), I still have a lot to learn before I can write my entire programs in one line
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-14-2018 , 08:44 PM
8 space tabs itt
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-14-2018 , 09:23 PM
#!/usr/bin/perl
$e="the it";
$d="the quick brown fox quick fox fox brown it jumped";
while($d=~/(\w+)/g){if($e!~/$1/){$c{$1}++}}
foreach$n(sort{$c{$b}<=>$c{$a}}keys%c){print"$n $c{$n}\n"}

fox 3
quick 2
brown 2
jumped 1
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-14-2018 , 10:32 PM
Quote:
Originally Posted by jmakin
got a code golf problem for you guys

term frequency counter, where we want the top 25 terms in a text file, with a list of stop words to not include. the text file is read from command line and stop words are contained in a .txt file as well

can't use python, c++, ruby, scala, or clojure

I have a pretty hilarious java solution.

shield your eyes (graded on # of chars, I got ~1100 which is pretty decent i think)

the readable solution was ~20ish lines

Spoiler:
Code:
import java.io*;import java.util.*;public class FrequencyCounter61{public class Word implements Comparable<Word>
{public String wo;public int fr;public Word(){}public Word(String s, int f){wo=s;fr=f;}
public int compareTo(Word w){if(this.fr>w.fr)return-1;else if(this.fr==w.fr)return 0;
else return 1;}}public static ArrayList<String> pi(Scanner i, ArrayList<String> s){ArrayList<String> o=new ArrayList<String>();
i.useDelimiter("[^A-Za-z]+");while(i.hasNext()){String w=i.next().toLowerCase();if(!s.contains(w)&&w.length()>1)o.add(w);}return o;}
public static void main(String[] args) throws FileNotFoundException{ArrayList<String> p=pi(new Scanner(new File(args[0])),
pi(new Scanner(new File("stop_words.txt")),new ArrayList<String>()));FrequencyCounter61 fq=new FrequencyCounter61();
ArrayList<Word> t=new ArrayList<Word>();int count = 0;String s;while(p.size()>0){s=p.get(0);
while (p.remove(s)) count++;t.add(fq.new Word(s, count));count=0;}Collections.sort(t);
for(int i=0;i<25;i++){System.out.println(t.get(i).wo + " - " + t.get(i).fr);}}}
Learn to use java streams, imo. I haven't tested this or bothered with the reading from input/from file. Have fun scrolling horizontally!

Code:
public String countFreq(String input, String stopWords) {

System.out.println(Arrays.stream(input.split("\\w+")).collect(Collectors.groupingBy(x -> x, Collectors.counting())).entrySet().stream().filter(x -> !Arrays.asList(stopWords.split("\\w+")).contains(x.getKey())).sorted((x,y) -> y.getValue().compareTo(x.getValue())).limit(25).map(x -> x.getKey() + ": " + String.valueOf(x.getValue())).collect(Collectors.joining("\n\r")));

}
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-14-2018 , 10:36 PM
Will break if there's punctuation, be a pretty easy fix tho (change the regex. too lazy). I'd say the entire thing (reading from file etc) can be done in one line, minus exception handling.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-14-2018 , 10:43 PM
Quote:
Originally Posted by goofyballer
I still have a lot to learn before I can write my entire programs in one line
Well for starters, you've used the Enter key a few times there, that's a no-no.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-14-2018 , 10:43 PM
Oh that’s way different than mine. My first instinct was to implement comparable on a class that stores the string and its frequency because hash map solutions are really messy and disgusting
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-14-2018 , 11:12 PM
Quote:
Originally Posted by ChrisV
Will break if there's punctuation, be a pretty easy fix tho (change the regex. too lazy). I'd say the entire thing (reading from file etc) can be done in one line, minus exception handling.
I thought of that after I posted. As well as words like don't.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-15-2018 , 12:20 AM
Quote:
Originally Posted by jmakin
Oh that’s way different than mine. My first instinct was to implement comparable on a class that stores the string and its frequency because hash map solutions are really messy and disgusting
If you see a HashMap, it can be easily dealt with via the first rule of Java Club: Immediately convert all streamable objects into streams.

Rule 2 is: Basic Strings are occasionally exceptions to Rule 1.

Quote:
Originally Posted by blacklab
I thought of that after I posted. As well as words like don't.
The word "DON'T" was definitely coming to mind while writing the above monstrosity.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-15-2018 , 01:54 AM
Chris - i may mess around with it later but I had to be extremely careful with how I decided to do things because the file we're parsing is pride and prejudice which is an extremely large book and has about ~11,000 unique words.

For instance, I learned the hard way (I had forgotten) that Strings are immutable in java. So yea, str = str+= "text" destroys and creates a new object each time. Good way to throw a outOfMemoryError which I've never even seen. Gotta use StringBuilder if you want to build a really large string.

I've been coding a ****load of C in my other classes and the result is, after years of being a java devotee, that I think java sucks ass. This Frequency Counter program really brought me to my knees.

The class takes a few different programming styles and has you re-implement the frequency counter in a different way each week, which is cool. But sometimes it makes me have to use some features of the language that are just annoying.

When something goes wrong in C, or even C++ for that matter, it's almost always gonna be my fault. When something goes wrong in java, who ****ing knows. Reading documentation and stackexchange to figure out how exactly they implemented a certain class is just so tedious. And then there's all the weird java trickery involved to do things that may seem pretty easy - yea right, try sorting a HashMap by its values.

Then I learn hashmaps actually ****ing suck. ConcurrentModificationExceptions whenever you try to modify an object that you're iterating through in a for:each loop is ****ing annoying and I had forgotten about that. HashMap<E> hm = new HashMap<E>(other hashmap) straight up doesn't work sometimes. Having to implement your own hash functions, etc. etc. Oh yea, on my own machine I was able to create an anonymous object for my subclass even though i did not declare a default constructor - on the school's unix cluster it threw a ton of exceptions and i had to declare a blank constructor. so much for compile once run anywhere.

My actual breaking point is that there is NO ****ING TUPLE in java. Like that would've simplified the problem so much. Every single other language has it or some super easy way to recreate it - but no, I have to declare my own subclass and implement comparator to get it to work with my program, or include a separate file. Either that or use SimpleEntry in a super strange way that was definitely not intended.

Just such a ****ing pain in the ass. It does some things really well - it's probably always my go to language for any problem involving parsing, because java streams are just so good and Scanner is a truly amazing library. But everything that goes along with it just made me rage hard today, having to learn so many stupid things the hard way wasted me about 3 hours I really could've used working on other stuff. It creates SOOOO many objects and uses so much space to do the simplest things, it's insane.

Last edited by jmakin; 04-15-2018 at 01:59 AM.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-15-2018 , 02:50 AM
Quote:
try sorting a HashMap by its values
Rule 1 of Java Club.

Code:
HashMap<String, Integer> a = someHashMap;
a.entrySet().stream().sorted(Comparator.comparing(Map.Entry::getValue)).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e2, HashMap::new));
Java is the ****ing worst. I come from C#, which is like Java that is actually intuitive, is richly-featured and works, so coming to Java is like getting downgraded from power tools to a hammer and chisel. Java streams are a hell of a lot better than having no functional programming at all, but LINQ in C# is about a zillion times better. The main problem with Java streams is that they are unintuitive and the errors are all utterly incomprehensible. For instance, if I try to assign the result of the above to a HashMap<String, Integer>, everything is fine. But if I try to assign it to, say, a List<String>, this is the result:

Quote:
Error: (73, 126) java: incompatible types: inference variable R has incompatible bounds
upper bounds: java.util.List<java.lang.String>,java.util.Map<K,U >,java.lang.Object
lower bounds: java.util.HashMap<K,V>
OK, something about incompatible types, no big deal, we'll just mouse over the toMap and see what type it produces...



Oh.

In C# it will just go "yo, this produces a Map<String, Integer> and that's not what your variable is". I don't get why it's hard, but Java streams always error out with total nonsense and I have to go google for what I'm doing wrong.

My favourite piece of Java hate, which I've posted before ITT, is that there's an Arrays.toList() method, which takes an array and produces an ArrayList. Easy! Except that this ArrayList is not a java.util.ArrayList, but a java.arrays.ArrayList, which looks and acts exactly the same unless you try to mutate it, in which case it will compile and then throw an exception at runtime. I consider this proof that the programmers of Java actually were trolling us.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-15-2018 , 10:49 AM
Quote:
Originally Posted by goofyballer
Am I JavaScripting correctly? Without being a full solution (assumes input is passed rather than adding a couple lines to read the files), this is (kind of) a one line solution and is 296 chars not including the added-for-readability comments: (also I didn't actually try running it so something's prob broken)
you didn't get much feedback but this looks pretty good other than I have never used Object.values in my life and its relatively new so uh not sure what you're doing there but maybe consider something else. Not that its wrong.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-15-2018 , 11:24 AM
Code:
cat source.txt | tr ' ' '\n' | sort | uniq -c | sort -nr | head -25
seems halfway there (not handling stopwords) and easy enough to slot in punctuation and whatever other refinements.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-15-2018 , 01:22 PM
Curious if anyone on here has much experience deploying and developing on windows platforms. I have an interesting opportunity presenting itself and I’m not sure if I want to take advantage of it or not. Just have a few questions I’d love to ask via pm.

TIA
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-15-2018 , 03:49 PM
Quote:
Originally Posted by jmakin
got a code golf problem for you guys

term frequency counter, where we want the top 25 terms in a text file, with a list of stop words to not include. the text file is read from command line and stop words are contained in a .txt file as well

can't use python, c++, ruby, scala, or clojure

I have a pretty hilarious java solution.

shield your eyes (graded on # of chars, I got ~1100 which is pretty decent i think)

the readable solution was ~20ish lines

Spoiler:
Code:
import java.io*;import java.util.*;public class FrequencyCounter61{public class Word implements Comparable<Word>
{public String wo;public int fr;public Word(){}public Word(String s, int f){wo=s;fr=f;}
public int compareTo(Word w){if(this.fr>w.fr)return-1;else if(this.fr==w.fr)return 0;
else return 1;}}public static ArrayList<String> pi(Scanner i, ArrayList<String> s){ArrayList<String> o=new ArrayList<String>();
i.useDelimiter("[^A-Za-z]+");while(i.hasNext()){String w=i.next().toLowerCase();if(!s.contains(w)&&w.length()>1)o.add(w);}return o;}
public static void main(String[] args) throws FileNotFoundException{ArrayList<String> p=pi(new Scanner(new File(args[0])),
pi(new Scanner(new File("stop_words.txt")),new ArrayList<String>()));FrequencyCounter61 fq=new FrequencyCounter61();
ArrayList<Word> t=new ArrayList<Word>();int count = 0;String s;while(p.size()>0){s=p.get(0);
while (p.remove(s)) count++;t.add(fq.new Word(s, count));count=0;}Collections.sort(t);
for(int i=0;i<25;i++){System.out.println(t.get(i).wo + " - " + t.get(i).fr);}}}
At a glance...

Seems very inefficient. As a rule of thumb, never use remove() or contains() on an ArrayList, unless you know for fact the size is small (< 10 items).

Also, names should be descriptive. It's not clear what `pi` does just by looking at its name, and why it's called multiple times.

Program flow should be:

1) Dump stop_words into a hash
2) Iterate through words file. Skip if word present in stop_words, else initialize/update count.
3) Dump hash key/values in an array. If the array's size > 25, sort it by values.

Last edited by :::grimReaper:::; 04-15-2018 at 03:55 PM.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-15-2018 , 06:06 PM
I see the board game on Amazon. What events led you to decide to turn it into an online game?

Last edited by OmgGlutten!; 04-15-2018 at 06:18 PM.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-15-2018 , 10:54 PM
Quote:
Originally Posted by ChrisV
Well for starters, you've used the Enter key a few times there, that's a no-no.
But it's all one statement (except the lambda in reduce()), don't hate because I made it readable.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-15-2018 , 10:59 PM
Quote:
Originally Posted by Grue
you didn't get much feedback but this looks pretty good other than I have never used Object.values in my life and its relatively new so uh not sure what you're doing there but maybe consider something else. Not that its wrong.
What's standard to accomplish what Object.entries does, something like

Object.keys(arr).map(key => [key, arr[key]])

?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-16-2018 , 12:16 AM
oh if you absolutely must iterate through the values of an object/assoc. array Object.entries is perfect obv but its basically never happened to me where I need to be like "oh I have this object and I need to perform x on all of its values and make something new out of that" which makes me wonder wtf you're doing or your api dev is doing but again I can't imagine its really that bad if you need to do it. There's (probably?) a reason Object.entries was made. I abuse the **** out of Object.keys frankly i.e. I could probably do it better.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote

      
m