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.
 
  • Locked thread
Bloody
Mar 3, 2013

wavefront is a thing

Adbot
ADBOT LOVES YOU

Funk In Shoe
Apr 20, 2008

Waiting in line, Mr. Haydon told me it is a wheel not meant for lovers but for infants, lifting people and letting them swing, putting the world on display from up high

jony ive aces posted:

so is "wavefront" an established term for a breadth first search or is it just that one guy's blog

I... don't know?

Bhodi
Dec 9, 2007

Oh, it's just a cat.
Pillbug

Bloody posted:

wavefront is a thing
a thing you do to your eyeballs

vodkat
Jun 30, 2012



cannot legally be sold as vodka
I just wanted to say i figured out my problem as I was trying to ask about it here :unsmith:

gonadic io
Feb 16, 2011

>>=

vodkat posted:

I just wanted to say i figured out my problem as I was trying to ask about it here :unsmith:

i know you might feel like a terrible programmer for doing this but seriously, this is entirely routine for me (well more on stack overflow than here but still)

jesus WEP
Oct 17, 2004


i think every coder rubber ducks sometimes!

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

Bloody posted:

wavefront is a thing

Alias|Wavefront

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...
I wonder if SO tracks how many times people hit "new question", type out a bunch of poo poo into the text box, then close the tab

oh no blimp issue
Feb 23, 2011

i asked about doing permutations using recursion on snackoverflow once and no one seemed to understand what i was talking about

fritz
Jul 26, 2003

Dessert Rose posted:

I wonder if SO tracks how many times people hit "new question", type out a bunch of poo poo into the text box, then close the tab

saves the mods the trouble of closing the question

crazysim
May 23, 2004
I AM SOOOOO GAY

Dessert Rose posted:

I wonder if SO tracks how many times people hit "new question", type out a bunch of poo poo into the text box, then close the tab

do you mean like facebook statuses?

Jerry Bindle
May 16, 2003
"hmm maybe the world doesn't need to know about the huge dump i'm taking" -- applies to facebook and stackoverflow equally well

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

crazysim posted:

do you mean like facebook statuses?

yeah, i know fb does it, but id like to see stats for so

Luigi Thirty
Apr 30, 2006

Emergency confection port.

I have this F# program:

code:
open System
open System.IO
open System.Text

let rnd = System.Random()

type PlayingCard(rank) =
    member this.Rank = rank

    member this.Name =
        match (this.Rank % 13) with
        | 0 -> "A"
        | 10 -> "J"
        | 11 -> "Q"
        | 12 -> "K"
        | _ -> (this.Rank % 13).ToString();

    member this.Suit =
        match this.Rank with
        | x when x >= 0 && x < 13 -> "s"
        | x when x >= 13 && x < 26 -> "c"
        | x when x >= 26 && x < 39 -> "h"
        | x when x >= 39 && x < 52 -> "d"
        | _ -> "?"

    member this.DisplayName =
        let sw = new StringBuilder()
        sw.AppendFormat("{0}{1}", this.Name, this.Suit)

    member this.ToString =
        this.DisplayName.ToString()

let DisplayHand hand =
    let sw = new StringBuilder()
    for card : PlayingCard in hand do
        sw.AppendFormat("{0}{1} ", card.Name, card.Suit) |> ignore
    sw.ToString()

let MakeRandomCard = new PlayingCard(rnd.Next(0, 52))
let DealHand = [MakeRandomCard; MakeRandomCard]

[<EntryPoint>]
let main argv = 
    let playerHand = DealHand
    let dealerHand = DealHand
    printfn "Player: %s" (DisplayHand playerHand)
    printfn "Dealer: %s" (DisplayHand dealerHand)
    0
the result of every MakeRandomCard is the same and I can't figure out why. rnd is in global scope so it shouldn't be re-seeding it with the system time four times in the same instant. if I replace them with just inlining new PlayingCard(rnd.Next(0, 52)) it works.

AWWNAW
Dec 30, 2008



Luigi Thirty posted:

I have this F# program:

code:
open System
open System.IO
open System.Text

let rnd = System.Random()

type PlayingCard(rank) =
    member this.Rank = rank

    member this.Name =
        match (this.Rank % 13) with
        | 0 -> "A"
        | 10 -> "J"
        | 11 -> "Q"
        | 12 -> "K"
        | _ -> (this.Rank % 13).ToString();

    member this.Suit =
        match this.Rank with
        | x when x >= 0 && x < 13 -> "s"
        | x when x >= 13 && x < 26 -> "c"
        | x when x >= 26 && x < 39 -> "h"
        | x when x >= 39 && x < 52 -> "d"
        | _ -> "?"

    member this.DisplayName =
        let sw = new StringBuilder()
        sw.AppendFormat("{0}{1}", this.Name, this.Suit)

    member this.ToString =
        this.DisplayName.ToString()

let DisplayHand hand =
    let sw = new StringBuilder()
    for card : PlayingCard in hand do
        sw.AppendFormat("{0}{1} ", card.Name, card.Suit) |> ignore
    sw.ToString()

let MakeRandomCard = new PlayingCard(rnd.Next(0, 52))
let DealHand = [MakeRandomCard; MakeRandomCard]

[<EntryPoint>]
let main argv = 
    let playerHand = DealHand
    let dealerHand = DealHand
    printfn "Player: %s" (DisplayHand playerHand)
    printfn "Dealer: %s" (DisplayHand dealerHand)
    0

the result of every MakeRandomCard is the same and I can't figure out why. rnd is in global scope so it shouldn't be re-seeding it with the system time four times in the same instant. if I replace them with just inlining new PlayingCard(rnd.Next(0, 52)) it works.

probably because make random card is a variable and not a function. put parentheses after it so that it takes a unit as input and returns a new playing card every time. same with deal hand

AWWNAW
Dec 30, 2008

also I'd do the whole thing in a more functional style and throw in some discriminated unions

Shaggar
Apr 26, 2006

Luigi Thirty posted:

I have this F# program:

code:
open System
open System.IO
open System.Text

let rnd = System.Random()

type PlayingCard(rank) =
    member this.Rank = rank

    member this.Name =
        match (this.Rank % 13) with
        | 0 -> "A"
        | 10 -> "J"
        | 11 -> "Q"
        | 12 -> "K"
        | _ -> (this.Rank % 13).ToString();

    member this.Suit =
        match this.Rank with
        | x when x >= 0 && x < 13 -> "s"
        | x when x >= 13 && x < 26 -> "c"
        | x when x >= 26 && x < 39 -> "h"
        | x when x >= 39 && x < 52 -> "d"
        | _ -> "?"

    member this.DisplayName =
        let sw = new StringBuilder()
        sw.AppendFormat("{0}{1}", this.Name, this.Suit)

    member this.ToString =
        this.DisplayName.ToString()

let DisplayHand hand =
    let sw = new StringBuilder()
    for card : PlayingCard in hand do
        sw.AppendFormat("{0}{1} ", card.Name, card.Suit) |> ignore
    sw.ToString()

let MakeRandomCard = new PlayingCard(rnd.Next(0, 52))
let DealHand = [MakeRandomCard; MakeRandomCard]

[<EntryPoint>]
let main argv = 
    let playerHand = DealHand
    let dealerHand = DealHand
    printfn "Player: %s" (DisplayHand playerHand)
    printfn "Dealer: %s" (DisplayHand dealerHand)
    0
the result of every MakeRandomCard is the same and I can't figure out why. rnd is in global scope so it shouldn't be re-seeding it with the system time four times in the same instant. if I replace them with just inlining new PlayingCard(rnd.Next(0, 52)) it works.

you are calling rnd.next once when it is passed as a parameter to the delegate.

AWWNAW
Dec 30, 2008

like i think your program would be much simpler if used types like these and don't even bother with making "classes" that have to be instantiated
code:
type Rank =
	| Bullshit of int
	| Ace
	| Jack
	| Queen
	| King

type Suit = 
	| Spade
	| Club
	| Heart
	| Diamond
	
type PlayingCard = {
	Rank: Rank
	Suit: Suit
}

AWWNAW
Dec 30, 2008

also you probably want to generate a sequence or list of all possible cards, also known as the deck, and randomly draw from that. otherwise you could end up dealing the exact same card more than once. that'd be awful

~Coxy
Dec 9, 2003

R.I.P. Inter-OS Sass - b.2000AD d.2003AD

Dessert Rose posted:

I wonder if SO tracks how many times people hit "new question", type out a bunch of poo poo into the text box, then close the tab

to be fair, the automatic "similar question" search results from the Ask Question window can be / are usually more relevant than the google results

Luigi Thirty
Apr 30, 2006

Emergency confection port.

AWWNAW posted:

also you probably want to generate a sequence or list of all possible cards, also known as the deck, and randomly draw from that. otherwise you could end up dealing the exact same card more than once. that'd be awful

I haven't gotten that far yet

when I wrote this on my microcontroller to save memory I drew random(0, 51) and compared it to each of the hands until there were no duplicates

gonadic io
Feb 16, 2011

>>=
god i'd hate to live in a world where having a single array of 10 vs 50 ints was a concern. it's not like you're running thousands of these in parallel

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

Luigi Thirty posted:

I haven't gotten that far yet

when I wrote this on my microcontroller to save memory I drew random(0, 51) and compared it to each of the hands until there were no duplicates

ah good, the possibly-never-halting implementation

probably ok if you only ever have 10-15 cards out at once though

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...
but really an entire deck fits in 52 bytes. 26 if you want to try and pack them into ... words? words are 4 bits, right?

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...
I'm pretty sure the code to iterate all the cards already dealt is larger than the size of the deck array would be

Luigi Thirty
Apr 30, 2006

Emergency confection port.

I used the seven card Charlie rule to make sure that wouldn't happen

also yes storing the deck would probably be easier

Potassium Problems
Sep 28, 2001

Dessert Rose posted:

but really an entire deck fits in 52 bytes. 26 if you want to try and pack them into ... words? words are 4 bits, right?

nibbles are 4 bits I think

Share Bear
Apr 27, 2004

meatpotato posted:

hi(g_pTerrible_programmers);

Put yourself in my life for a moment: Work is me doing nasty embedded systems bitch work on a tight schedule to make rich people expensive toys, it puts the fear in me that I'll never move past insignificant work with slow microcontrollers.

One day I think: man, wouldn't it be cool to work remotely, travel and live an fulfilling life? Maybe if airport security didn't think my projectos are bombas this could work nicely. Maybe I should look into other tech sub-fields. It's not too unfamiliar that it's scary. I am going to become an interesting person. This will be great. Excitement builds inside me. YOSPOS, kill my dumb dreams.

I work for the only tech company in town and I walk to work somewhere in a nicer part of the (extended) SF bay area. Rent is cheap, house is nice, I live downtown, salary is not good for SF but decent here but my work is meaningless garbage. With these (super) first word problems and no internal direction, what would Y'ALLSPOS do?

save a ton of money until you can do that or support yourself for a couple of years while you try

tef
May 30, 2004

-> some l-system crap ->

meatpotato posted:

hi(g_pTerrible_programmers);


get out and meet a bunch of people at meetups

Lime
Jul 20, 2004

Dessert Rose posted:

but really an entire deck fits in 52 bytes. 26 if you want to try and pack them into ... words? words are 4 bits, right?

7 bytes if you just use bit flags, can't shuffle it but if you're already looping to check for duplicates

Lime fucked around with this message at 18:58 on Oct 5, 2015

Jerry Bindle
May 16, 2003

Lime posted:

7 bytes if you just use bit flags, can't shuffle it but if you're already looping to check for duplicates

you could represent the deck in 6 bytes for dealing the cards, but you'd still need a separate data structure for representing an individual card, or a hand of cards. a single card takes 6 bits, a hand of 2 cards could be represented in 11 bits, a hand of 5 in 22 bits.

Jerry Bindle fucked around with this message at 20:51 on Oct 5, 2015

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

Dessert Rose posted:

I wonder if SO tracks how many times people hit "new question", type out a bunch of poo poo into the text box, then close the tab

gotta be a lot. i get notifications whenever a question is posted with our tag and like 10% of questions are already deleted when i click on it a minute later

NihilCredo
Jun 6, 2011

iram omni possibili modo preme:
plus una illa te diffamabit, quam multæ virtutes commendabunt

Barnyard Protein posted:

you could represent the deck in 6 bytes for dealing the cards, but you'd still need a separate data structure for representing an individual card, or a hand of cards. a single card takes 6 bits, a hand of 2 cards could be represented in 11 bits, a hand of 5 in 22 bits.

profligate wastrel. you can represent the entire game in 52 * log (N + 2) bits where N is the number of players. use bit flags to mark whether each card is in the deck, in the discard pile, or in a given player's hand

Jerry Bindle
May 16, 2003

NihilCredo posted:

profligate wastrel. you can represent the entire game in 52 * log (N + 2) bits where N is the number of players. use bit flags to mark whether each card is in the deck, in the discard pile, or in a given player's hand

:worship:

Luigi Thirty
Apr 30, 2006

Emergency confection port.

I made an Atari breakout clone years ago. the secret trick I had to save ROM space was that when the level was drawn, it was made using background tiles. a row was 8 bits long but 12 bricks wide. the level data was fed from the ROM into the TIA as background tiles so I mirrored the background at exactly the right time that the left third of the level mirrored the right third.

then you do the mirror in software when copying the brick bitfields into RAM and you've saved 24 BITS PER LEVEL of ROM space (6 rows of 8 bricks instead of 6 rows of 12 bricks) and your level fits cleanly into 6 bytes of RAM

I never wrote enough levels for this to make any difference whatsoever because the core game logic was 1.5kb and my compiler did 4kb cartridges anyway

pepito sanchez
Apr 3, 2004
I'm not mexican
design is hurting my head because i AM making a card game and have my cards neatly made and loaded and everything in the domain with their behavior but they also have to be in the UI for display and they all have the same everything but also exactly one additional attribute in the constructor (the location of the loving card's image) and i really don't like it at all because knowing when to separate logic from UI is retarded and stupid....... sometimes

pepito sanchez
Apr 3, 2004
I'm not mexican
the worst part is the game is conga. a game exactly 0.1% of the world play or know. a game i understand but have never played because it's a stupid rear end card game

Jerry Bindle
May 16, 2003
don't worry about the API design, how many bytes does the card model consume??

j/k API design is hard. you could implement it using two interfaces: one that deals with the logic, and another that cares about the view. the instances of the concrete class realization of those interfaces would combine the two, but the methods that operated on the logic and the view would be separated.

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
still trying to come up with questions to ask people to find out if they know how to program good

Adbot
ADBOT LOVES YOU

pepito sanchez
Apr 3, 2004
I'm not mexican
eh it's all design. it's assumed we already know everything about the language itself already. efficiency is left for the algorithms and data structures class. not a care in the world here, though i know you're joking :) but yeah it's both cool and terrifying working with observer and facade and so many other patterns in conjunction for the first time. it's like i worked with mvc by complete accident with c# at this point.

however my one project partner just literally broke his right (good) hand punching a wall out of gayness. so that leaves 4 simultaneous projects almost up to just me and it's slowly creeping up to "a lot of stuff." this is me venting on the yos. i prolly posted that already somewhere but come on. how do you break your loving hand. PLS

  • Locked thread