Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
PIZZA.BAT
Nov 12, 2016


:cheers:


Yeah I’m looking for a black box essentially that I brute force into figuring out how to play the game via the final scoring. The problem is a lot of games I have in mind, poker for example, it’s impossible to know if a particular move is correct or not at the specific point in time. It has to be grounded against for tens of thousands of hands before you start to see if it’s a winning strategy or not. Not to mention things like bluffing

Keep in mind I’m a complete newb when it comes to this field so if my aim is totally off you can point me towards a better methodology

Adbot
ADBOT LOVES YOU

ultrafilter
Aug 23, 2007

It's okay if you have any questions.


Reinforcement learning works well for a lot of games, but poker is a special case that needs its own algorithms.

PIZZA.BAT
Nov 12, 2016


:cheers:


Yeah poker specifically is the one i’ve been most interested in because it’s so hard.

I may have to write something bespoke

ultrafilter
Aug 23, 2007

It's okay if you have any questions.


I haven't been following the research lately but the last I saw counterfactual regret minimization is the gold standard for poker AIs. It's very unlikely that you'll find something off the shelf for that, though.

PIZZA.BAT
Nov 12, 2016


:cheers:


lol i literally just finished watching a 30 minute talk by the guys who just made the news with that technique. yeah what they did is way more advanced than what i’m capable of

to be clear i’m not trying to solve it or anything. this is just for fun. i want to see if i can get something that can at least pass as a human player

ultrafilter
Aug 23, 2007

It's okay if you have any questions.


Depending on what you mean by that, it's at least extremely difficult. In general, one of the hardest problems in AI is creating systems that make the same sort of mistakes that humans do. You might get a poker bot that can compete with amateur players, but not something that passes the Turing test for poker.

PIZZA.BAT
Nov 12, 2016


:cheers:


yeah that was worded awkwardly sorry. i’m just looking to wind up with something that’s actually playing the game and not going off a bunch of hard coded rules. ideally something that taught itself how to play. whatever pops out on the other side will probably have very strange behaviors that won’t at all be human but they’ll at least be… competent? this is just a side project / curiosity that i want to work on. i’m starting to think what i’m asking for may not exist though

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?
Are you talking about training a neural network to play poker ala AlphaGo? I don't think that's infeasible. That kind of thing has been done for boardgames by plenty of people. I was looking into trying to do something similar with a board game I play but couldn't find many good resources at the time.

PIZZA.BAT
Nov 12, 2016


:cheers:


Yeah again i’m a total idiot when it comes to this stuff so while i’ve heard of alphago i have zero comprehension of the technical underpinnings of how it works.

Let me type up a more thorough explanation of my vision tomorrow morning when I have some time. brb

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

PIZZA.BAT posted:

Yeah again i’m a total idiot when it comes to this stuff so while i’ve heard of alphago i have zero comprehension of the technical underpinnings of how it works.

Let me type up a more thorough explanation of my vision tomorrow morning when I have some time. brb

If you created a thread in CoC or project.log I'd read it.

I find the area interesting but have been too bone idle so far to explore it myself, beyond reading about it

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?

PIZZA.BAT posted:

Yeah again i’m a total idiot when it comes to this stuff so while i’ve heard of alphago i have zero comprehension of the technical underpinnings of how it works.

Let me type up a more thorough explanation of my vision tomorrow morning when I have some time. brb

If you just google search for "poker neural network" you'll get a bunch of github projects. Here's one at random that learns from playing itself (I think that was something you wanted): https://github.com/dickreuter/neuron_poker

Also a ML thread seems like it would be a good idea but I don't have enough experience (or time these days) to start one.

ultrafilter
Aug 23, 2007

It's okay if you have any questions.


I don't think I can write an OP that people in CoC would be interested in, but I'd definitely follow a thread someone else wrote.

Macichne Leainig
Jul 26, 2012

by VG
What sort of stuff would constitute a good thread? I have a basic idea of how a lot of ML stuff works and some hands on experience with all kinds of ML (not reinforcement learning or game AI neural networks though). Happy to put a thread together, but I doubt I’m the most knowledgeable in the subject.

ultrafilter
Aug 23, 2007

It's okay if you have any questions.


Honestly? Just start a thread with an OP based on what you know, and reserve the second post to link to good posts from other people.

Kuule hain nussivan
Nov 27, 2008

I've wanted to get into contributing to open source projects for a while, but it always turns into a very daunting task. Both finding worthwhile projects and then figuring out how to contribute to them.

Any tips? Or would there be any interest in starting a goon group to get things done together?

CarForumPoster
Jun 26, 2013

⚡POWER⚡

Kuule hain nussivan posted:

I've wanted to get into contributing to open source projects for a while, but it always turns into a very daunting task. Both finding worthwhile projects and then figuring out how to contribute to them.

Any tips? Or would there be any interest in starting a goon group to get things done together?

I have not done this beyond extremely minor things so I can't provide that much help but the little I have done has been from finding a project I actually use and care about which has open issues on GitHub? Usually popping into their slack or whatever chat channel or sending an email to the owners to ask if they accept PRs if I fork and make the fixes.

Is there some friction there? If you mean contributing new features, I'd try starting with doing some maintenance/bug fixes since usually people don't want to do that and everyone wants to make new features.

nielsm
Jun 1, 2009



Contributing to a larger/older project is likely to take more effort, since they're more likely to have strict guidelines in place, and for anything larger than trivial bug fixes probably need to fit into a "vision" on some level.
On the other hand with a smaller project it's more likely it might be on slow maintenance from the developer(s) and take much longer from you try to submit anything until you get a reaction.

Regardless, one of the best moves is to try joining whatever IRC or Slack or other chat the project has and try asking for suggestions on things to work on.

Remember that contributing to a project can also be writing documentation (for end users or for developers), or documenting reported bugs, like describing a reliable minimal reproduction or write a regression test for the bug.
A fine entry point can even be setting up a development environment for yourself and documenting any trouble you had, to improve the developer documentation.

Macichne Leainig
Jul 26, 2012

by VG
So there's surely a better way to handle environment-specific configuration values and secrets than what I'm doing (which, to be clear, is effectively nothing.)

It worked fine when it was just me on the team, but now our company is starting to add new developers and I want to clean this up so it's easier for anyone to deploy a new instance of our platform.

Just want like, a centralized place where I can stick config values that can be read from both JavaScript and Python as well if at all possible.

I have a feeling this is a solved problem already, I just don't apparently know how to find it myself online.

General_Failure
Apr 17, 2005
This may well need its own thread. But I hope not.
I need to take a HEX file and split it out into two HEX files for high and low bytes of 16 bit words.

Long story short I built a Gigatron kit computer and not only do I have no way of programming a 27C1024 EPROM, but I accidentally bought the OTP version of the ROM. However I did dig out a couple of 8 bit flash chips. I can handle the hardware side and programming, but I just wanted to know if there was a way of splitting up a HEX file before I go and write a program to do it.

So, do I have to do it or is there a solution already available?

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

Protocol7 posted:

So there's surely a better way to handle environment-specific configuration values and secrets than what I'm doing (which, to be clear, is effectively nothing.)

It worked fine when it was just me on the team, but now our company is starting to add new developers and I want to clean this up so it's easier for anyone to deploy a new instance of our platform.

Just want like, a centralized place where I can stick config values that can be read from both JavaScript and Python as well if at all possible.

I have a feeling this is a solved problem already, I just don't apparently know how to find it myself online.

Are you looking for environment variables? Or something platform specific like apples keychain?

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

General_Failure posted:

This may well need its own thread. But I hope not.
I need to take a HEX file and split it out into two HEX files for high and low bytes of 16 bit words.

Long story short I built a Gigatron kit computer and not only do I have no way of programming a 27C1024 EPROM, but I accidentally bought the OTP version of the ROM. However I did dig out a couple of 8 bit flash chips. I can handle the hardware side and programming, but I just wanted to know if there was a way of splitting up a HEX file before I go and write a program to do it.

So, do I have to do it or is there a solution already available?

You can probably do this with xxd and awk. You may find it easier to write a small utility.

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?

General_Failure posted:

This may well need its own thread. But I hope not.
I need to take a HEX file and split it out into two HEX files for high and low bytes of 16 bit words.

Long story short I built a Gigatron kit computer and not only do I have no way of programming a 27C1024 EPROM, but I accidentally bought the OTP version of the ROM. However I did dig out a couple of 8 bit flash chips. I can handle the hardware side and programming, but I just wanted to know if there was a way of splitting up a HEX file before I go and write a program to do it.

So, do I have to do it or is there a solution already available?

This should be a very simple program. What languages are you familiar with? Here's a SO on reading a file byte by byte in python for example: https://stackoverflow.com/questions/1035340/reading-binary-file-and-looping-over-each-byte. After that all you have to do is alternately write the bytes to the two output files.

Macichne Leainig
Jul 26, 2012

by VG

leper khan posted:

Are you looking for environment variables? Or something platform specific like apples keychain?

I mean I guess environment variables would work fine for this, but I guess I didn't know if there was something better out there for that purpose.

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

Protocol7 posted:

I mean I guess environment variables would work fine for this, but I guess I didn't know if there was something better out there for that purpose.

Everything other than env vars I know of is language or platform specific. Admittedly not something I worry about daily.

Macichne Leainig
Jul 26, 2012

by VG
I mean that should still work fine for my needs honestly. No reason to find another solution if that covers 99% of what I'm looking for and the support is already out there.

General_Failure
Apr 17, 2005

HappyHippo posted:

This should be a very simple program. What languages are you familiar with? Here's a SO on reading a file byte by byte in python for example: https://stackoverflow.com/questions/1035340/reading-binary-file-and-looping-over-each-byte. After that all you have to do is alternately write the bytes to the two output files.
Funny, that. I had a go at splitting out the binary ROM file in Python yesterday. Thing is I don't know python. I kind of ran aground when it came to variable formats, lists etc. I think I'll just do it in C. It was an interesting foray into Python at least.


leper khan posted:

You can probably do this with xxd and awk. You may find it easier to write a small utility.

xxd is useful. I used it to turn a ROM file into an array recently so I could embed an emulator on a Pi Pico. I was thinking maybe using the ROM binary, divvying it out to high and low byte files, then hex-ifying them using xxd.

Funny thing is earlier in the week I wrote most of a hex file generator for an Arduino Mega so I could dump an Apple 2 clone keyboard ROM. My program has bugs, but the ROM has much worse so I never bothered finishing it. Now I've got to do pretty much the opposite and do a hex reader.

tbqh I have no idea how to use awk.

General_Failure
Apr 17, 2005
I knocked out a little C program to split the ROM into high and low bytes. Or rather data and instruction. The Gigatron uses 8 bits for instruction and 8 bits for data on a 16 bit ROM. So endian-ness is pretty irrelevent.
Now I just have to work out the rest.

e: I threw together an Arduino Mega based programmer for the flash. Now I'm trying to get the flash to do something. The datasheet is horrendous. I can't work out if the writer liked puzzles, or was getting ready to leave with no notice. The waveform diagrams are the most helpful thing in it.

General_Failure fucked around with this message at 08:36 on Jun 19, 2021

Quebec Bagnet
Apr 28, 2009

mess with the honk
you get the bonk
Lipstick Apathy

Protocol7 posted:

I mean that should still work fine for my needs honestly. No reason to find another solution if that covers 99% of what I'm looking for and the support is already out there.

If you need to store secrets, there's always Vault.

General_Failure
Apr 17, 2005
Just dropping in to say I solved the hex file splitting issue.
I sort of circumvented the whole thing. What I did was wrote a small C program to split the ROM binary out into two files of alternating bytes. It took me a very long time, but eventually I got my breadboarded flash programmer to perform some basic functions to the flash chip.
After looking at my options for sending the ROM files to the flash via serial I dug out a micro sd card module and just set it up to write a binary file from SD card to the flash chip. That was actually the easiest part.
So now I have a couple of chips with what I need on them. Sorted!

Gin_Rummy
Aug 4, 2007
Wondering if anyone might be able to recommend a method in Python with which I could take a string of, lets say 80 characters (complete words/sentences), and break it into a list/array where each index is a new line... but the kicker is I don't want to throw to a new line if I am not pulling an entire word.

Split seems like it would do some of what I want to do (keeping words together), and I found something on StackOverflow that would do the other half (split after a certain character count)... but I am not sure of a way to bridge the two. Someone pointed me towards regular expressions, but I'm not sure I fully understand what is going on by using something like that.

csammis
Aug 26, 2003

Mental Institution

Gin_Rummy posted:

Wondering if anyone might be able to recommend a method in Python with which I could take a string of, lets say 80 characters (complete words/sentences), and break it into a list/array where each index is a new line... but the kicker is I don't want to throw to a new line if I am not pulling an entire word.

It sounds like you want to make a function that implements a word wrap at n characters. What’s the definition of an “entire word,” like does hyphenation or multiple language support matter to your use case?

quote:

Split seems like it would do some of what I want to do (keeping words together), and I found something on StackOverflow that would do the other half (split after a certain character count)... but I am not sure of a way to bridge the two.

Split may be annoying when it comes time to reconstruct whatever token you split on. I think generally you’ll want to start by taking a substring of n characters from the start of the source string. Determine if the end of the substring is in the middle of a “word” (likely) and if so backtrack to the nearest word boundary and put whatever’s left as its own line. Start your next substring of length n at the index in the source string where you ended up splitting the last one.

quote:

Someone pointed me towards regular expressions, but I'm not sure I fully understand what is going on by using something like that.

I’m not sure this person has your best interest at heart, but maybe they meant use a regular expression to find a word boundary?

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?

Gin_Rummy posted:

Wondering if anyone might be able to recommend a method in Python with which I could take a string of, lets say 80 characters (complete words/sentences), and break it into a list/array where each index is a new line... but the kicker is I don't want to throw to a new line if I am not pulling an entire word.

Split seems like it would do some of what I want to do (keeping words together), and I found something on StackOverflow that would do the other half (split after a certain character count)... but I am not sure of a way to bridge the two. Someone pointed me towards regular expressions, but I'm not sure I fully understand what is going on by using something like that.

So there are a lot of edge cases (some mentioned above) that you haven't specified. But a general approach would be to first split the string into a list of words (using split, or something fancier if that doesn't suit your requirements), then reassemble the words into lines, subject to the line length limit you have.

xtal
Jan 9, 2011

by Fluffdaddy
This may by what you're looking for: https://docs.python.org/3/library/textwrap.html#textwrap.wrap

StashAugustine
Mar 24, 2013

Do not trust in hope- it will betray you! Only faith and hatred sustain.

I don't suppose anyone has good resources for working with LabView? I did a bit of work with it in college but now I'm trying to get a grasp on a pretty massive program and I'm not quite sure where to start

Volguus
Mar 3, 2009

StashAugustine posted:

I don't suppose anyone has good resources for working with LabView? I did a bit of work with it in college but now I'm trying to get a grasp on a pretty massive program and I'm not quite sure where to start

Oh, LabView. Haven't touched it since 1998, 2nd year in university. Can't say I miss it, though I'm sure it improved in the decades past.

Gin_Rummy
Aug 4, 2007

csammis posted:

I’m not sure this person has your best interest at heart

This made me laugh quite a bit and I forwarded it to the recommender.

That being said, re.findall actually worked for me:

quote:

foo = re.findall(r".{20}\S*", bar)

for i in foo
`````do stuff

In any case, I appreciate all the suggestions. I think textwrap probably would have ended up being simpler to wrap my head around if I came by it first.

foutre
Sep 4, 2011

:toot: RIP ZEEZ :toot:
I want to make something like this: https://pubgheatmap.net/; basically a replay webapp that uses an API to get the data.

From looking through similar projects, it seems like React + Canvas for the frontend, and then GraphQL on the backend is pretty standard. I haven't done a ton of front-end stuff in the past, and have basically only used the MERN stack for those projects.

The one thing that I think I'd like to change from that setup is the data processing - it looks like the way they deal with updating the telemetry data is one huge javascript file (https://github.com/mediusoft/PUBG-heatmap-frontend/blob/dev/src/models/Telemetry.parser.js), that updates a 'state' object over 400 or so lines. If possible, I'd rather use Python for populating the model data, and processing whatever I get back from the database (i.e., doing data manipulation/visualization in pandas/np/seaborn). Is this a situation where Flask would make sense slotted into the React/Canvas combo, or should I just be using Dash instead? I've only seen projects in Dash that are kind of basic dashboards for showing graphs and whatnot, but as far as I can tell it's basically just React in Python, so maybe it would be just as good? Is there some other combination that would be better?

Basically I've got no idea what tool to use, I usually just do data/ML stuff that doesn't have much to do with anything front end, and am a bit lost re: what's best.

CarForumPoster
Jun 26, 2013

⚡POWER⚡
I really like dash and would gladly answer any questions you want. Super easy to deploy to heroku. If a Python graphing library, plotly or cytoscapes can make the plot you want you can do the whole thing in Python.

Is that the case here? If no it starts to be more complicated.

EDIT: I reread your post and you said you can do it using seaborn. In that case you can probably use dash and you might check out plotly because it’s pretty but seaborn works too. Plotly has the advantage of being integrated in dash with dcc.Graph()

EDIT2: https://plotly.com/python/animations/

CarForumPoster fucked around with this message at 14:30 on Jun 23, 2021

foutre
Sep 4, 2011

:toot: RIP ZEEZ :toot:
That's exactly what I was wondering, thanks! It sounds like Dash would be a good fit. The one more complicated thing is the map itself - basically, it's a static image of the map with little dots and bullet tracers and stuff drawn on it. It sounds like it might be complicated to do with just the plotly animations, but it looks like there's a dash version of canvas, which is what I've used in React so that seems promising. I'm honestly kind of mad I didn't realize there was a version of this where I could be using Python instead of JS all along...

If you're up for it I've got some very basic questions:

Are there any go-to resources you'd suggest looking at for learning Dash? I'm comfortable with Python in general, but (as you can tell) very new to Dash.

Is the Dash framework pretty similar to React? Ie, model-view-controller decomposition and whatnot?

How do you handle getting data in Dash? I.e., in React I basically use Mongoose and Express; is there an equivalent set of things I should be looking at for Dash?

E: more generally re the above, it looks like a lot of the examples load in data beforehand rather than ie asynchronously getting data from a server. Is that a design choice that's necessary, or just kind of because that's the form data happens to be in? Ie, you could do it either way, but usually don't have to.

Thanks again for the help!

foutre fucked around with this message at 18:35 on Jun 23, 2021

Adbot
ADBOT LOVES YOU

CarForumPoster
Jun 26, 2013

⚡POWER⚡

foutre posted:

That's exactly what I was wondering, thanks! It sounds like Dash would be a good fit. The one more complicated thing is the map itself - basically, it's a static image of the map with little dots and bullet tracers and stuff drawn on it. It sounds like it might be complicated to do with just the plotly animations, but it looks like there's a dash version of canvas, which is what I've used in React so that seems promising. I'm honestly kind of mad I didn't realize there was a version of this where I could be using Python instead of JS all along...

If you're up for it I've got some very basic questions:

Are there any go-to resources you'd suggest looking at for learning Dash? I'm comfortable with Python in general, but (as you can tell) very new to Dash.

Is the Dash framework pretty similar to React? Ie, model-view-controller decomposition and whatnot?

How do you handle getting data in Dash? I.e., in React I basically use Mongoose and Express; is there an equivalent set of things I should be looking at for Dash?

E: more generally re the above, it looks like a lot of the examples load in data beforehand rather than ie asynchronously getting data from a server. Is that a design choice that's necessary, or just kind of because that's the form data happens to be in? Ie, you could do it either way, but usually don't have to.

Thanks again for the help!

I haven't used React, although Dash uses React to render the UI (i.e. the webpage you interact with).

The thing I like about Dash vs, say, Django, is you don't really need to think about any of those things you just said. You can make that pubg simulator without knowing what a MVC is. Just use the callback to run the python code you'd normally write for a regular python program.

For example: If you have the data sitting on the server already you can load it when the app runs (for example using pandas like pd.read_csv() or pd.read_sql(). Callbacks run async by default in current Dash IIRC. So to make an app like the pubg simulator you linked where it starts with empty data and then updates it with a button press and lets say the match data is requested from a rest API, you'd just make the button use requests to hit the API.


IDK if this code works I havent tested it or thought about it much, but should be the right concept:
code:
### This code renders a scatter plot using a callback loading data first from a dataframe then, after a button is pressed, from an API. 

# Your imports and stuff
import dash
import dash_html_components as html
import dash_core_components as dcc
import pandas as pd
import plotly.express as px
import requests

external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']

app = dash.Dash(__name__, external_stylesheets=external_stylesheets)

### Higher up you have a graph with some ID and a button
app.layout = html.Div([
    html.Button('Submit', id='btn-id-name', n_clicks=0),
    dcc.Graph(figure=None, id="graph-figure") 
    # IDK if you can actually make this None or if it needs some init.
    # Either way in the callback I say to get it some init data if the button hasn't been pressed yet.
])


# Down lower youll have your callback.
@app.callback(Output('graph-figure', 'figure'),
              [Input('btn-id-name', 'n_clicks')])
def some_func_name(n_clicks):
    if n_clicks: # If you've clicked the button. 
        headers = {
            "Content-Type": "application/json",
        }
        response = requests.get(
            f'https://api.dickbutt.com/api/v1/?param=bad_posting',
            auth="ABC123", headers=headers)

        # Do some stuff to the response here, make your fig
        new_fig = px.scatter(
            pd.DataFrame(response.json()),
            x="sepal_width",
            y="sepal_length"
        )
        return new_fig
    else: # If you have NOT clicked the button. 
        # Read in some initial data set if you want some starter thing. All callbacks are executed at runtime.
        df = pd.read_csv("init_data.csv")
        # Make some initial figure
        fig = px.scatter(df, x="sepal_width", y="sepal_length")
        return fig
    

if __name__ == '__main__':
    app.run_server(debug=True)
I didnt use dash bootstrap components but you should because they're easy and make stuff prettier.

CarForumPoster fucked around with this message at 22:41 on Jun 23, 2021

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply