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
KillHour
Oct 28, 2007


Pakistani Brad Pitt posted:

Thanks for all of the very quick answers (and the detail, KillHour/Dominoes)!

This all makes good sense to me, and I think you pretty much answered my followup, which was going to be "What if the rules of Monopoly limited the supply of money to what is physically shipped in a set?". (e.g. if you draw a "Collect $200" card, you can only collect it as 2 $100 bills if there are still 2 $100 bills in the bank, but you could also take twenty $10 bills, or 1 $100 and two $50's, etc.)

In that case, it seems like it would be a good idea to make an Bill-type object and methods to move/store them in Player or Bank owned arrays to represent the money? It seems like you could also do this by keeping a counter integer for each bill type and incrementing/decrementing it all the time to keep track?

hashmap/dictionary with the face value as the key and the quantity remaining as the value.

Objects only make sense if you're going to store information in them. The bill itself has no properties that you care about.

Edit: Yes I know empty classes and structs are a thing but I'm trying to keep it simple.

Double Edit: You might be thinking "But the bill does have a property - its value" and you could do that, but then you'd have to iterate through the entire array of bills every time you wanted to find one of a certain type. Which, I admit, is more true to the actual game, but it's really inefficient.

KillHour fucked around with this message at 20:13 on May 25, 2020

Adbot
ADBOT LOVES YOU

Dr. Stab
Sep 12, 2010
👨🏻‍⚕️🩺🔪🙀😱🙀

Pakistani Brad Pitt posted:

Thanks for all of the very quick answers (and the detail, KillHour/Dominoes)!

This all makes good sense to me, and I think you pretty much answered my followup, which was going to be "What if the rules of Monopoly limited the supply of money to what is physically shipped in a set?". (e.g. if you draw a "Collect $200" card, you can only collect it as 2 $100 bills if there are still 2 $100 bills in the bank, but you could also take twenty $10 bills, or 1 $100 and two $50's, etc.)

In that case, it seems like it would be a good idea to make an Bill-type object and methods to move/store them in Player or Bank owned arrays to represent the money? It seems like you could also do this by keeping a counter integer for each bill type and incrementing/decrementing it all the time to keep track?

Even in that case, rather that throw around bill objects, I would just make a MoneySupply object, with properties like num20, num100, etc. Then, you can write methods like totalMoney() or canMakeExactChange(). Then, give each player and the bank their own MoneySupply.

The idea here is that all the code that cares about fiddling with money goes in the money class, and other classes only need to think about money in a broad sense.

e: also, later, if you decide you need individual bill objects, you can just change the implementation of the MoneySupply class and not have to touch a bunch of different places.

Dr. Stab fucked around with this message at 20:20 on May 25, 2020

KillHour
Oct 28, 2007


Dr. Stab posted:

Even in that case, rather that throw around bill objects, I would just make a MoneySupply object, with properties like num20, num100, etc. Then, you can write methods like totalMoney() or canMakeExactChange(). Then, give each player and the bank their own MoneySupply.

The idea here is that all the code that cares about fiddling with money goes in the money class, and other classes only need to think about money in a broad sense.

e: also, later, if you decide you need individual bill objects, you can just change the implementation of the MoneySupply class and not have to touch a bunch of different places.

This is a good way to do it. You can also give MoneySupply a method to return the quantities of each bill for displaying on screen.

mystes
May 31, 2006

Dr. Stab posted:

Even in that case, rather that throw around bill objects, I would just make a MoneySupply object, with properties like num20, num100, etc. Then, you can write methods like totalMoney() or canMakeExactChange(). Then, give each player and the bank their own MoneySupply.

The idea here is that all the code that cares about fiddling with money goes in the money class, and other classes only need to think about money in a broad sense.

e: also, later, if you decide you need individual bill objects, you can just change the implementation of the MoneySupply class and not have to touch a bunch of different places.
I wouldn't make things like "num20" a property because you might need to iterate over all the denominations. As previously suggested, a hashtable might be a better choice.

Dominoes
Sep 20, 2007

Pakistani Brad Pitt posted:

Thanks for all of the very quick answers (and the detail, KillHour/Dominoes)!

This all makes good sense to me, and I think you pretty much answered my followup, which was going to be "What if the rules of Monopoly limited the supply of money to what is physically shipped in a set?". (e.g. if you draw a "Collect $200" card, you can only collect it as 2 $100 bills if there are still 2 $100 bills in the bank, but you could also take twenty $10 bills, or 1 $100 and two $50's, etc.)

In that case, it seems like it would be a good idea to make an Bill-type object and methods to move/store them in Player or Bank owned arrays to represent the money? It seems like you could also do this by keeping a counter integer for each bill type and incrementing/decrementing it all the time to keep track?
Python code:
enum Bill:
    One(1)
    Five(5)
    Ten(10)
    Twenty(20)
    // etc

class State:
    bank_money: List<Bill>
    // (other fields)

class Player:
    money: List<Bill>  // instead of the number I used in the above ex
    // (other fields)

fn make_change(amount: int, bills: List<Bill>) -> Result<List<Bill>>:
    // Program logic goes here that determines how you'd like to
    // select bills to meet the amount.
    // The result is wrapped in an optional type that succeeds if you can
    // make exact change, and fails if not. (perhaps the fail case gives you the
    // closest result instead of just failing)

As KillHour mentioned, it might be easier to store a hashmap/dict of the bills instead of a list, since that would make updating it easier. Or a Bank class that has fields for each bill. (I'd go with a class over a hashmap, since you want to hard code which bills are allowed, and want a single source for defining/referencing which these are) If the order of the bills is important, something like what I have above would be better. Ie, maybe use a list for the deck, and a hashmap/bank class for the bank.

Dominoes fucked around with this message at 21:11 on May 25, 2020

baka kaba
Jul 19, 2003

PLEASE ASK ME, THE SELF-PROFESSED NO #1 PAUL CATTERMOLE FAN IN THE SOMETHING AWFUL S-CLUB 7 MEGATHREAD, TO NAME A SINGLE SONG BY HIS EXCELLENT NU-METAL SIDE PROJECT, SKUA, AND IF I CAN'T PLEASE TELL ME TO
EAT SHIT

I'd use an enum if you got em because you get the lookup (Enum.values or whatever) and also the type safety (a hashmap can't guarantee it contains a given key, but you can always get a value from an enum instance)

Dominoes
Sep 20, 2007

For make change, do y'all think we're looking at solving a linear system of equations? That's where I'd start, although you'd have to think about how you'd handle the under-constrained case, since this is what you'll hit most often. Depending on the language using, there may be a linear algebra lib that handles this concisely. Could use least squares as the closest match if unable to make exact change, or make it so you only overpay the bank, not under etc.

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
The "optimal" strategy is to always take payment in solely one dollars until they run out, which is only limited by how much of a pain in the rear end it is to do that.

Are you going to model the banker shifting bank money to their personal funds whenever they are called upon to make change?

Pakistani Brad Pitt
Nov 28, 2004

Not as taciturn, but still terribly powerful...



Jabor posted:

The "optimal" strategy is to always take payment in solely one dollars until they run out, which is only limited by how much of a pain in the rear end it is to do that.

Are you going to model the banker shifting bank money to their personal funds whenever they are called upon to make change?

Haha it’s a bad example, I just wanted to keep the analogy while broaching the concept of game pieces which are not unique (but are limited in quantity by the game rules). This has been helpful, thanks y’all.

Dominoes
Sep 20, 2007

baka kaba posted:

I'd use an enum if you got em because you get the lookup (Enum.values or whatever) and also the type safety (a hashmap can't guarantee it contains a given key, but you can always get a value from an enum instance)
Agreed. Main issue with the enum approach is the filtering code is messier than a field or hash lookup.

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
I agree with everybody that every note shouldn't be an object in this case but I want to commend you for having that thought. Most of the time, I'm dealing with new programmers that just want to cram everything into one giant function in a single file.

Dominoes
Sep 20, 2007

When the OOP question came about, I was worried about the other side: Java or 90s C++ programmers trying to wrap everything in nested classes with private fields!

taqueso
Mar 8, 2004


:911:
:wookie: :thermidor: :wookie:
:dehumanize:

:pirate::hf::tinfoil:

surely we can use multiple inheritance more in this situation

KillHour
Oct 28, 2007


taqueso posted:

surely we can use multiple inheritance more in this situation

If you really think about it, a player is also kind of a house.

Dr. Stab
Sep 12, 2010
👨🏻‍⚕️🩺🔪🙀😱🙀
Player 1 is a kind of player, which is a kind of money haver, which is a kind of thing haver, which is just another word for associative array.

Dominoes
Sep 20, 2007

Please stop.

b0lt
Apr 29, 2005
We keep track of each bill individually:

code:
class PlayerBills : public std::vector<bool> {
};

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!

KillHour posted:

If you really think about it, a player is also kind of a house.

Both are just empty containers for garbage, just like my head and my career.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Dominoes posted:

Please stop.

ever seen a typescript project featuring classes with seven levels of multiple inheritance, yet no type definitions, and all the private members of the class are typed "any"? i have. it's the only project i've seen that was actually made worse by the use of typescript.

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

Rocko Bonaparte posted:

Both are just empty containers for garbage, just like my head and my career.

All encapsulated safely inside of you're posts

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!

Volmarias posted:

All encapsulated safely inside of you're posts

And that is what makes me a rock star developer!

Dominoes
Sep 20, 2007

Bruegels Fuckbooks posted:

ever seen a typescript project featuring classes with seven levels of multiple inheritance, yet no type definitions, and all the private members of the class are typed "any"? i have. it's the only project i've seen that was actually made worse by the use of typescript.
I try not to read other people's TS/JS code, for mental health.

I submitted a PR once to a Python dt library called Arrow to de-obfuscate excessive class wrappings. I think it involved classes existing solely for generating other classes. Didn't get anywhere. I later realized the library was pathologically designed from API to code. Turns out it based its API on an equally well-designed, and even more popular JS lib.

Dominoes fucked around with this message at 14:30 on May 28, 2020

Hadlock
Nov 9, 2004

Are there any US-based banks that provide an API where I can pull back my current balance amount

Paul MaudDib
May 3, 2006

TEAM NVIDIA:
FORUM POLICE

Hadlock posted:

Are there any US-based banks that provide an API where I can pull back my current balance amount

Virtually all banks provide OFX Direct Connect protocol, but it seems to be described as "complex and archaic".

Maybe you can piggyback off GnuCash or some other library/package though.

Hadlock
Nov 9, 2004

On further inspection there's Plaid they have an API and the free tier would allow me to pull back the balance of one account, which is all I need

Somewhat leery of handing my banking info over to a startup just to get my balance. Looks like Plaid is just literally screen scraping the website in most cases, which seems horribly inefficient but whatever

Looking at gnucash they have support for it looks like us bank, most of the integrations are for bank's stock trading platforms, which I don't especially care about. US Bank ofers ofx support for $3.95/mo I think, based on the doco I saw

The RECAPITATOR
May 12, 2006

Cursed to like terrible teams.
Just curious if there's a dedicated machine learning thread in here. I scanned the thread titles and couldn't readily identify anything obvious. Or is all that sort of discussion happening in the Python thread?

SurgicalOntologist
Jun 17, 2004

There are these two in SAL: #DataScience and Scientific/Math(s) Computing.

Combat Pretzel
Jun 23, 2004

No, seriously... what kurds?!
Anyone here knows Visual Foxpro?

I'm in a new position doing statistical stuff, and have to take over a bunch of Foxpro apps. I've been messing around with it, and there's already a bunch of puzzling things I can't find an answer to. For instance, the main irritating thing is that for some reason I can't instantiate a class into variables a to j.

Doing this fails:

code:
a = CREATEOBJECT("foo")
a.bar
Breaks with "Unknown verb" on the second line. Whereas this works:

code:
k = CREATEOBJECT("foo")
k.bar
But doing ?a tells me variable not found.

Like what the gently caress? :psypop:

Also, any good resources to get up to date on this poo poo?

ultrafilter
Aug 23, 2007

It's okay if you have any questions.


"up to date" and "Visual Foxpro" don't really go together. Is there a reason why you can't switch to a technology that's been updated since 2007?

Combat Pretzel
Jun 23, 2004

No, seriously... what kurds?!
My predecessor took over a bunch of Foxpro applications for statistical bullshit and pretty much stuck with it. He's now moving up in the department, I'm taking over that poo poo. The goal down the line is to start rewriting things in something modern. However meanwhile minor work is probably needed adding minute features to the existing stuff, and maintenance when IT is loving around with table and column names on their DB2 server.

I don't even have a plan for how to proceed anyway. Been a while I actively coded. Since they're staying Microsoft centric (in regards to client computing anyway), I'm probably gonna go with C# and embedding a browser control to generate printable reports. Or some poo poo like that.

Combat Pretzel fucked around with this message at 22:23 on May 30, 2020

AgentCow007
May 20, 2004
TITLE TEXT
How do you go about converting random bits (like from a hardware RNG) into constrained results? For example if I want to randomly pick from [A-Za-z0-9] (62 values), using 6 bits of random data (64 values), do I have any options besides mod (which would bias the first two characters) or discarding out-of-range values (wasting muh precious entropy)?

Hadlock
Nov 9, 2004

Visual FoxPro is just a warmed over version of FoxPro with some compatibility layer for running on Windows 2000 AFAIK

FoxPro is the rebranding of something else, I think Microsoft bought them as part of their embrace extend extinghish campaign in the late 1990s. I worked at a place that put a foxpro system in place back in 1998 or so and even then it wasn't exactly cutting edge technology... good luck

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

AgentCow007 posted:

How do you go about converting random bits (like from a hardware RNG) into constrained results? For example if I want to randomly pick from [A-Za-z0-9] (62 values), using 6 bits of random data (64 values), do I have any options besides mod (which would bias the first two characters) or discarding out-of-range values (wasting muh precious entropy)?

If you're just generating a single selection then not really, although the entropy in that case doesn't really matter. If you were really penny pinching then you can realize that if you got an out-of-range result, which of the two you got gives you back one bit of entropy.

If you were generating a whole bunch of these then you could construct an elaborate scheme to harvest every bit of entropy from previous generations that didn't end up in the final value and use them to eventually use one fewer bit when generating a future value. It's almost certainly more work than just pulling the extra values from your source though.

MJP
Jun 17, 2007

Are you looking at me Senpai?

Grimey Drawer
I've never taken a programming class since the days of Logowriter in grade school. I'm having trouble getting my brain around the syntax, logic, etc. of Powershell and JSON as they relate to Azure infrastructure-as-code. I can figure out how to get a Powershell cmdlet to do something, or how to sorta futz an existing ARM template to do what I need, but if it's anything more than that - e.g. adding an additional resource to an ARM template, properly nesting cmdlets in a script, etc., it just turns into me hurling copy/pasted code into something until it either works or I get frustrated, spend more time on it, and reach the point where I've spent too much time automating a task and I'm better off just doing it in the GUI.

I was thinking of auditing a community college Intro to Computer Programs course since I learn really well in class environments, where there's feedback from a live teacher, someone to ask questions in real time, etc. The next offering my local CC has is in the fall semester, so I was wondering if there was a similar experience online somewhere. It doesn't have to be free, it doesn't have to be for credit, but it does need to have interaction between the faculty and students more than just emailing questions. e.g. something like a regularly scheduled chat session, Zoom call, etc. where people can work together and/or with the faculty.

Does such a thing exist? I just need to start from the basics, how programming languages operate, how to turn a command and its switches into a proper script or program. It really needs to have that interpersonal part - I don't know enough of the basics to have the self-discipline to be able to learn from a book like I did when I was studying for Microsoft/VMware/Amazon exams.

DoctorTristan
Mar 11, 2006

I would look up into your lifeless eyes and wave, like this. Can you and your associates arrange that for me, Mr. Morden?

AgentCow007 posted:

How do you go about converting random bits (like from a hardware RNG) into constrained results? For example if I want to randomly pick from [A-Za-z0-9] (62 values), using 6 bits of random data (64 values), do I have any options besides mod (which would bias the first two characters) or discarding out-of-range values (wasting muh precious entropy)?

You are trying to construct a map from each of 64 possible inputs to one of 62 possible outputs. A simple application of the pigeonhole principle shows that you can’t do this without either (i) at least one output that multiple inputs map to, or (ii) some inputs that map to nothing.

As you point out, doing (i) will bias the distribution of the output, so with a single input your only option is (ii) - if you get one of the unmapped values you throw it away and try again with a fresh rng call (this is known as ‘rejection sampling’)

Alternatively you could do what the poster above suggested and consume additional inputs to generate a longer sequence of outputs - a quick calculation shows you’d need to consume 31 random 6-bit inputs to generate a sequence of 32 random symbols. The benefit of this is that you’re now making fewer calls per symbol to the (presumably expensive ) hardware rng.

(Unless you’re doing something critical like generating cryptographic keys, worrying about ‘muh entropy’ is probably overthinking it and some flavour of prng will usually be fine for the vast majority of use cases )

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!

MJP posted:

I've never taken a programming class since the days of Logowriter in grade school. I'm having trouble getting my brain around the syntax, logic, etc. of Powershell and JSON as they relate to Azure infrastructure-as-code. I can figure out how to get a Powershell cmdlet to do something, or how to sorta futz an existing ARM template to do what I need, but if it's anything more than that - e.g. adding an additional resource to an ARM template, properly nesting cmdlets in a script, etc., it just turns into me hurling copy/pasted code into something until it either works or I get frustrated, spend more time on it, and reach the point where I've spent too much time automating a task and I'm better off just doing it in the GUI.
I can't really help you with finding an actual course but I wanted to reassure you about PowerShell. I find it kind of a nightmare where a lot of my experience with a lot of other programming languages falls flat. A lot of that has to do with the whole culture of shell scripting that has been crammed into it. That's a world that has a lot of tribal knowledge and quirks. The cmdlets set some minimum acceptable standard, but you will find yourself wondering why this or that thing deliberately does not work in a way you expect. The piping and shorthand is also difficult to follow but is an essential part of people mashing away with this stuff in one-off things on their command line. If you're walking into that world trying to get a clean understanding of the more general practice of programming then you're going to be fighting the language.

Paul MaudDib
May 3, 2006

TEAM NVIDIA:
FORUM POLICE
is there a free-standing open source product that handles event logging? I was thinking it would be nice if instead of a flat text log, we had a database type thing with customizable retention policies for various event types, etc. So we could do things like query by user, session, or the class that caused the exception, have it automatically purge low-level debug info after a week or two but hold onto errors longer, etc.

Obviously would not be hard to build something like that with a regular old database and a log4j2 database appender but I seem to remember something like that existing off the shelf. Apache Kafka maybe?

ultrafilter
Aug 23, 2007

It's okay if you have any questions.


Take a look at OpenTelemetry.

Hadlock
Nov 9, 2004


Someone described this as the output of smooshing jaeger and... some competing open standard together, and it has a "driver" for Prometheus, is that about correct?

Has anyone actually used this in prod yet? What were your experiences

Looks interesting, and it's an official CNCF project, but seems new to me

Adbot
ADBOT LOVES YOU

Blinkz0rz
May 27, 2001

MY CONTEMPT FOR MY OWN EMPLOYEES IS ONLY MATCHED BY MY LOVE FOR TOM BRADY'S SWEATY MAGA BALLS

Paul MaudDib posted:

is there a free-standing open source product that handles event logging? I was thinking it would be nice if instead of a flat text log, we had a database type thing with customizable retention policies for various event types, etc. So we could do things like query by user, session, or the class that caused the exception, have it automatically purge low-level debug info after a week or two but hold onto errors longer, etc.

Obviously would not be hard to build something like that with a regular old database and a log4j2 database appender but I seem to remember something like that existing off the shelf. Apache Kafka maybe?

This is the basic use case for an ELK stack

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