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

04-11-2013 , 09:06 AM
I don't know anything about C++, but I do know a bit about C, so the following is somewhat educated blind guessing. I noticed that at 92 you have:

Code:
*(ptrFlights[i]).getDeparture()
while at 100 you have:

Code:
*ptrFlights[i].getDeparture
It seems they can't both be right.

Looking at the error message, it seems like this might be an order of operations issue, in that it's trying to .getDeparture before dereferencing the pointer.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-11-2013 , 09:08 AM
What did the debugger say when you asked it about that line?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-11-2013 , 10:04 AM
Quote:
Originally Posted by gaming_mouse
just a guess, as my C++ is very rusty, but I think "." has higher precedence than "*" dereference operator, so maybe try:

if ( (*prtFlights[i]).getDestination==myDesination )
Yup, thanks.

Quote:
Two other things:
- are you sure getDestination is not a method, ie, did you forget parens? getDestination()
- this code needs to be cleaned up badly
It is and I did, which presumably would have returned another error if I was dereferencing the pointer correctly.

Can you give me some pointers as to how I should clean up my code?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-11-2013 , 10:33 AM
Quote:
Originally Posted by SenorKeeed
Can you give me some pointers as to how I should clean up my code?
sure. i think i'd be able to give you deeper insights if i had more info about surrounding code. can you give me:

* a list of the other public methods from the same class that this method was taken from, both static and instance methods

* a list of the collaborating classes, and their public methods
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-11-2013 , 10:58 AM
so here are a few quick things i noticed for now:

you recalculate the length of ptrFlights with every call. you shouldn't have to do this. since you are not using a smart pointer that would manage this directly, you could at least create a member variable to hold the current length. Then presumably you have an addFlight() method or something, and you could increment that variable when that method was called and a new flight added. this would remove that initial loop altogether: you'd simply always have access to a member variable with the correct length. if you insisted on keeping it for whatever reason, at least rewrite it as (untested):

int numFlights = 0;
while (ptrFlights[numFlights++] != 0) ; // loop does nothing but sets the correct numFlights.

Note I changed "count" to "numFlights" -- in general your variable names are not descriptive and they really need to be.

when you check for the correct departure and destination you use two loops. you can easily rewrite that as one succinct loop. i think you can figure out how to do that yourself though.

btw, sorry to keep harping on this, but i believe you are taking a class on C++ and i just can't emphasize enough how bad it is to learn programming this way. not criticising you, just whatever curriculum is making you do this. the effect is going to be to teach you a bunch of bad habits and get you acclimated to always seeing the trees instead of the forest , and perhaps make you dislike programming unfairly.

Last edited by gaming_mouse; 04-11-2013 at 11:04 AM.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-11-2013 , 11:03 AM
Haha yes I guess a static member variable numberFlights would probably make things easier. I see you're right about the two loops being unnecessary as well. Thanks.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-11-2013 , 11:07 AM
Quote:
Originally Posted by SenorKeeed
Haha yes I guess a static member variable numberFlights would probably make things easier. I see you're right about the two loops being unnecessary as well. Thanks.
yeah although prolly not static, since you could have instances of this class for each airline or whatever, and they would each have their own flight list.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-11-2013 , 11:09 AM
Yes, not static, thanks.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-11-2013 , 11:18 AM
Quote:
Originally Posted by SenorKeeed
hey guys, wondering if anyone can help me with this code. The line 92 doesn't work (as well as similar lines later in the function, I am getting this error:



What I think I'm doing in line 92 is the following: ptrFlights is an array of pointers to Flight objects. So, *(ptrFlights[i]) will dereference the pointer that is in the i element of the array, and *(ptrFlights[i]).getDeparture() will call the getDeparture function of the Flight object. What is my mistake here?

Oh, and is this the right place/thread for these kind of questions?
1. The operator you want is ->

ptrToThing->Method(); // easy to type correctly, idiomatic
(*ptrToThing).Method(); // easy to get wrong, unnatural

2. I think it would be easier / better with your own thread "SenorKeeed's adventures in C++".
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-11-2013 , 11:27 AM
Quote:
Originally Posted by gaming_mouse
btw, sorry to keep harping on this, but i believe you are taking a class on C++ and i just can't emphasize enough how bad it is to learn programming this way. not criticising you, just whatever curriculum is making you do this. the effect is going to be to teach you a bunch of bad habits and get you acclimated to always seeing the trees instead of the forest , and perhaps make you dislike programming unfairly.
Yes I am. Do you mean just taking a class in general is a bad way to learn programming? Do you mean a good way to learn programming is more ad hoc, learning what you need to learn to solve a particular problem?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-11-2013 , 11:30 AM
Quote:
Originally Posted by kerowo
What did the debugger say when you asked it about that line?
wp
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-11-2013 , 11:32 AM
and sorry for cluttering up this thread, I'll start a new thread if I have further questions so the only people who will be subjected to my programming AIDS are people who willfully click on my thread.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-11-2013 , 11:52 AM
Quote:
Originally Posted by SenorKeeed
Yes I am. Do you mean just taking a class in general is a bad way to learn programming? Do you mean a good way to learn programming is more ad hoc, learning what you need to learn to solve a particular problem?
i mean C++ is a bad starting language. i have no problem with classes...
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-11-2013 , 11:58 AM
Quote:
Originally Posted by tyler_cracker
wp
I was happy with it too but then I realized if it won't compile he won't be able to step to it probably.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-11-2013 , 08:07 PM
Quote:
Originally Posted by gaming_mouse
Dave, why not read js the good parts? Or have you already?
No, and I'm going to get that now, instead. I find it shocking to note that after 5 years, this is still the best javascript book available. I guess that Secrets of a JavaScript Ninja is supposed to be a book that finally outshines this, but come on, really?

I don't want to actually learn the language right now. I just want to know what is happening when I write (js/window) and go home.

I watched the JavaScript, the Good Parts video today and it was quite informative and entertaining. Then after hearing him talk about Scheme so much, I watched Sussman build the Meta Circular Evaluator. Two hours of total win.

Quote:
Originally Posted by clowntable
Better writing == better programming, didn't you hear? All the cool kids say so.
Yeah, but admittedly, that long post wasn't well-written. It's like over-commented code.

Quote:
daveT: How old are you again? Iirc oldish that got into programming late, right?
34. Started this stuff at 32, so going on two years.

Quote:
I kind of feel like you're some sort of bizzaro-me. I come to post that V 0.1 of my poker code is done...book you already created the thread. I come in here wanting to ask about JS-DG because I'm considering rewriting some/all of the Java part of the framework in JS eventually boom you post about the book (I'll stay away for now).
Yes, stay away. This review feels like it came out my pen and not someone else's.

Quote:
If you post about Elixir next week or something I'll check my security settings :P
How are you liking Erlang. Is it Erlang, really or a totally new language built on the VM?

Quote:
Originally Posted by Nchabazam
I'm sure nothing is replacing JS, I'm just getting bored writing straight backend rails with very little on the front end. I know there are tons of people who want sweet rich 1 page apps.

That's why I have side projects!

Also, the site I'm working on would really be a good candidate for a mostly 1 page experience, but since I'm basically the only dev it doesn't make sense now. Down the road I might try and spearhead that initiative.
Definitely wouldn't want to be a Rails-only dev all your life. That caboose will leave the station sooner than you expect and you don't want to become the equivalent of a Perl CGI scripter when you wake up tomorrow.

I'm not entirely sure if you'd be repulsed or embrace JavaScript to be honest. The language seems like the antithesis of everything Ruby stands for.

I think that Spiral echoed a common theme. He isn't the only poster here who has mentioned not being able to find a js developer after an 18-month search. Not sure what the issue is, but I suspect that they are looking for people with some CS chops to top off a disconcerting obsession with the language. Sounds like a real opportunity for the correct kind of weirdo. I wonder if that is what they sort of mean about js being the assembly language of the web: only sickos and oddballs can find real beauty in either assembly or js.

I think you'd be surprised at how fast you can learn a language, build, and ship code in that language if you really put effort into it. As long as you have some sensible and flexible baseline engineering, the rest of the abstractions can build up pretty nicely. I built that bot in less than a week and that is nearly 500 LOC in a language I kind of sort of knew. That bot is pretty algorithmic, and I didn't know much about that stuff in Clojure before starting. I can't really say much about the current quality of the code, but it is quite flexible and not hard to fix up, regardless. I had already known some Clojure and I've written quite a bit of Lisp already, so you may have different results.

Quote:
Originally Posted by Gullanian
EMCAScript v6 is next for the web with regards to Javascript.
http://en.wikipedia.org/wiki/ECMAScript

v6 has support for classes which will be great. Browsers should start adopting it later on this year iirc
Why is classes a good thing for javascript? More specifically, why should there be two diametrically opposed object viewpoints in the same language? I would think namespaces would be the best addition. Large systems can work very well without class systems, but not good file organization.

Quote:
Originally Posted by SenorKeeed
Haha yes I guess a static member variable numberFlights would probably make things easier. I see you're right about the two loops being unnecessary as well. Thanks.
Wait, you only did two loops and your just starting? That's awesome.

Quote:
Originally Posted by SenorKeeed
and sorry for cluttering up this thread, I'll start a new thread if I have further questions so the only people who will be subjected to my programming AIDS are people who willfully click on my thread.
eh, I do worse.

Last edited by daveT; 04-11-2013 at 08:16 PM.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-11-2013 , 08:27 PM
Quote:
Originally Posted by gaming_mouse
i mean C++ is a bad starting language. i have no problem with classes...
Depends.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-11-2013 , 10:54 PM
Oddly enough, I've been reading the javascript pocket reference by the same guy who wrote the definitive guide. Today I noticed that he uses a number of examples using anonymous functions before the chapter about functions, which is written as though targeted toward people who have never heard of a function before. Once again I find myself wondering "Who is the target audience again?"
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-12-2013 , 12:42 AM
I have to say, that Crockford guy is an impressive teacher and talker. He states his opinion of JS-DG in one of his teaching videos: "It's the least worst book on javascript out there." Not exactly a ringing endorsement.

It's little wonder why companies struggle to find js developers. There is only a handful of proven resources and the ratio of good to absolute trash is 1 to a 1000, and if JS-DG is any indication, there is no linear relationship here. How would anyone but the purest of nerds be able to parse out the trash? How many of these guys and gals want to bother with js when the glory is in other places?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-12-2013 , 08:17 AM
This is embarrassing, but what am I doing wrong here (see stove output below).

I want to manually arrive at the equity number for Hand0 based on the pots won and tied numbers. My thinking is:

total pots played = "pots won by Hand0" + "pots won by Hand1" + pots tied
total = 115299689 + 105543943 + 2798049
total = 223641681

hand0 equity = ("pots won" + 0.5*"pots tied")/total
hand0 equity = (115299689 + 0.5*2798049)/223641681
hand0 equity = 0.52181110863

But this does not agree with the stove answer .52154

Where's my mistake?

EDIT: nm, i figured it out. it should be:

(115299689 + 2798049)/(115299689 + 105543943 + 2798049 *2)


Code:
Text results appended to pokerstove.txt

 226,439,730  games     2.206 secs   102,647,203  games/sec

Board: Jd 7s 6d
Dead:  

	equity 	win 	tie 	      pots won 	pots tied	
Hand 0: 	52.154%  	50.92% 	01.24% 	     115299689 	  2798049.00   { A2s+, K2s+, Q2s+, J2s+, T2s+, 92s+, 82s+, 72s+, 62s+, 52s+, 42s+, 32s }
Hand 1: 	47.846%  	46.61% 	01.24% 	     105543943 	  2798049.00   { 22+, A2o+, K2o+, Q2o+, J2o+, T2o+, 92o+, 82o+, 72o+, 62o+, 52o+, 42o+, 32o }

Last edited by gaming_mouse; 04-12-2013 at 08:38 AM.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-12-2013 , 08:48 AM
This is useful. Your personal way back machine: http://archive.is/
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-12-2013 , 01:46 PM
Quote:
Originally Posted by daveT
I think that Spiral echoed a common theme. He isn't the only poster here who has mentioned not being able to find a js developer after an 18-month search. Not sure what the issue is, but I suspect that they are looking for people with some CS chops to top off a disconcerting obsession with the language. Sounds like a real opportunity for the correct kind of weirdo. I wonder if that is what they sort of mean about js being the assembly language of the web: only sickos and oddballs can find real beauty in either assembly or js.
Interesting insight, the best JS developer I know is a very strange, almost won't talk, writes amazing code, but very hard to work with.

There are a lot of people who know just a touch of JS, mainly work with jquery, cut and paste as their go-to style, and apply for any JS job that comes, which makes it a bit of a slog in hiring.

I haven't put in an 18 month search, i haven't even started actually, I assume that was a different poster?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-12-2013 , 03:46 PM
I can see there being a shortage of javascript devs because to begin learning backbone type frameworks you already have to know a server side language to set up the REST stuff and have some CSS chops to set up templates. It's a bit of a different skill set than the usual CS grad will have and the hacker news hipster webdev community is probably alot smaller than it appears.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-12-2013 , 07:20 PM
It was "hipster" like 2-3 years ago maybe. The idea of doing a lot of client side JS and having a light server acting as basically nothing more than an API server is ancient news at this point. It's not really an optimal solution though unless you really have some type of real application that you're running.

Rendering templates on the client kind of sucks in a lot of cases and #! is really bad.

I do like JS though. Really happy I investigated Node all those years ago and stuck with it + doing some more client side stuff recently.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-13-2013 , 12:07 AM
I've been getting into puppet recently. I really like the idea of using code in a VCS to define a server environment. It's a lot better than a collection of jankity shell/perl scripts.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-13-2013 , 12:23 AM
Quote:
Originally Posted by spiral
Interesting insight, the best JS developer I know is a very strange, almost won't talk, writes amazing code, but very hard to work with.
Does this guy think jQuery is a bloated piece of trash?

Quote:
I haven't put in an 18 month search, i haven't even started actually, I assume that was a different poster?
Sorry, I worded that poorly. There is a poster here who mentioned how difficult it was to find a JS dev. This is LA, so I don't know what impact that has on anything.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote

      
m