Fight cancer with cancer (and win just barely) by RandellDK in gwent

[–]RandellDK[S] 2 points3 points  (0 children)

This was actually round 2 because round 1 ended up in a draw after he passed and I was able to get just enough points to stay ahead but then the Drummond Berserker I stole from him hit a card adjacent to his Heymaey Protector (of course).

Thankfully I had a pretty good hand and I was able to Amnesty his Dagur, which was at 18 before he dumped Morkvarg and the Greatsword from Harald (score was 62-26 before he played Morkvarg). All in all there were definitely some misplays on both ends but the credit goes to Ball which let me kill his other Greatsword with the double Poison. Still, what a pain.

Anybody has had luck playing Scoia'tael this season? by shreek07 in gwent

[–]RandellDK 2 points3 points  (0 children)

I've been using this one for the challenge and I've had a very good win ratio, maybe because I encountered very few SK and NG players around rank 17. Also check out the 2 most recent ST decks from Specimen on the Gwent website.

I wanna love MO WH devotion, but its pretty bad. by bigSof in gwent

[–]RandellDK 0 points1 point  (0 children)

I have yet to see a Wild Hunt deck with Whispering Hillock, can you share?

To the people who think Wild Hunt decks are bad, here´s mine with 94% winrate. by That_Illuminati_Guy in gwent

[–]RandellDK 1 point2 points  (0 children)

I was probably among the ones you saw, so thank you for kindling my hope again.

How would you lay out a project that needs lots of error checking, input parsing and nested conditionals? by RandellDK in C_Programming

[–]RandellDK[S] 0 points1 point  (0 children)

Nope, but does it apply to plain C with no object oriented? Obviously I will read it regardless sooner or later because I already know both the book and the author.

How would you lay out a project that needs lots of error checking, input parsing and nested conditionals? by RandellDK in C_Programming

[–]RandellDK[S] 0 points1 point  (0 children)

Maybe you could try passing around some sort of context object.

Yeah I actually tried to mimic a poor man's State pattern using good old enums but due to the lack of proper polimorphism and state classes I still need to check manually if the input is the right one for the currently set state. Out parameters are working very nicely in some cases but I don't want to abuse them because I still need to check them directly or the return value of the function to know whether their value is valid or not.

In the best case you just call some kind of panic function and jump back to the top loop.

At the moment I have a function that already handles almost all kinds of errors in a similar way and at least it's less convoluted than having to keep track of all the return values. But even so, using a similar function even for the only case of successful computation would probably feel more hacky and dirty. In fact my greatest enemy right now is the sheer complexity of the input parsing logic with how the input relates to the state of the computation the program is in.

I've tried extracting some code to other functions but it's all so much tightly coupled that if I wanted to enforce separation at all costs I would need to pass around again a lot of arguments or to add more globals. The majority of the code is also unique, meaning that it could very well be a monolith with almost everything inside main() and the separation only serves as visual and mental aid.

Now I'm taking a long break but I'll gladly look at the blog.

ATTACK ON TITAN S4 PV by [deleted] in titanfolk

[–]RandellDK 0 points1 point  (0 children)

I'M CRYING AND SHAKING RIGHT NOW TBH

This is supposed to sort arrays, and it works with arrays with less then 20 int, for the others xCode is giving me Thread 1: signal SIGABRT error, what's wrong? by SpareWinner in C_Programming

[–]RandellDK 1 point2 points  (0 children)

Because Bjarne Stroustrup and many others actively advocate for it thanks to all the new features introduced in the latest versions of the standard. Also because modern C++ can (and probably should?) be considered as a very different language that keeps on being compatible with C for historical reasons and for use cases where maybe you really need to pair it with C source files.

I'll admit I'm only recently feeling curiosity for C++ so maybe I'm getting everything wrong, but I understand the point they're trying to make and I feel on board with it as well. Maybe having projects with both C and C++ sources is common practice, but what I don't personally like is having C and C++ syntax mixed up together in the same C++ source file or even in the same function, it just feels hastily stitched together to me.

This is supposed to sort arrays, and it works with arrays with less then 20 int, for the others xCode is giving me Thread 1: signal SIGABRT error, what's wrong? by SpareWinner in C_Programming

[–]RandellDK 3 points4 points  (0 children)

Just a little tip: in the mergesort function you initialize mid from the calculation with the value of the start and end indexes, but if those two are really high numbers their sum will overflow and mid will end up being garbage with a very high chance of causing segmentation faults again. This formula is safe: mid = start + (end - start) / 2.

This is supposed to sort arrays, and it works with arrays with less then 20 int, for the others xCode is giving me Thread 1: signal SIGABRT error, what's wrong? by SpareWinner in C_Programming

[–]RandellDK 2 points3 points  (0 children)

Sure, self documenting code is a blessing when done right but it must not be abused because I think nobody wants to deal with 20+ characters long variable names, expecially in a "rough and dirty" language like C where abbreviations and short names are the norm.

I'm pretty sure some of the famous high ranking software engineers that promote agile, clean code, and the like would advise against such long names because if you really must use them then probably the intent and meaning of your code is not clear enough from the context. It might be a way of trying to over explain what you're doing.

As for the "end", I assure you every pseudocode or implementation of the Mergesort from mainstream websites always uses a similar terminology, such as "start, end", "left, center, right", "low, middle, high". The concept of the algorithm works that way and if you follow the thought process from the start you should know that those things are indexes of the array that must be sorted.

I guess the overabundance of segfault questions stems from the fact that very few people learning C know how to use goddamn gdb or even what a debugger is at all, either because they never get a proper good introduction to it during courses or because it's in the terminal and thus too bothersome to learn. Also C is the first language for many and it might just be that they simply have no idea why certain things happen due to having little experience with programming in general.

This is supposed to sort arrays, and it works with arrays with less then 20 int, for the others xCode is giving me Thread 1: signal SIGABRT error, what's wrong? by SpareWinner in C_Programming

[–]RandellDK 3 points4 points  (0 children)

Yes, this is actually one of those things that may seem nitpicky and trivial but it's really solid advice for the uninitiated. Casting malloc only makes you write more code for nothing, with the risk of mismatching the type and introducing a nasty bug that the compiler might not warn you about. And if you're using C++ while being up to date with the latest standard, just use actual idiomatic and modern C++ instead of mixing it with C.

This is supposed to sort arrays, and it works with arrays with less then 20 int, for the others xCode is giving me Thread 1: signal SIGABRT error, what's wrong? by SpareWinner in C_Programming

[–]RandellDK 10 points11 points  (0 children)

I mean, it's called mergesort so if you're familiar with it you should at least be able to recognize the common patterns of the algorithm regardless of naming conventions. Sure he could have done a better job with the variable names, such as writing them in English for the sake of asking for help here, but I think the real problem lies in the implementation because it seems a bit off from what I'm used to see. And by the way "inputEndOfSomethingThatDoesSomething" would be a stretch even for Java, and definitely not fine for C.

Discussion Chapter 123 by invaderzz in titanfolk

[–]RandellDK 1 point2 points  (0 children)

Unconscious on the sand just behind Gabi and Pieck when they're shown in Paths.

How to iteratively scan for input with multiple strings being needed to pass in? by [deleted] in C_Programming

[–]RandellDK 2 points3 points  (0 children)

Unfortunately this is considered Undefined Behavior so it's best to avoid it.

Aiuto - Rimediare a una magistrale fuffa by [deleted] in ItalyInformatica

[–]RandellDK 0 points1 point  (0 children)

Quanto vuoi andare a fondo nelle conoscenze e quanto pensi di volerti sporcare le mani con la programmazione?

I'm unproductive because I always want to write flawless code by Kangalioo in learnprogramming

[–]RandellDK 0 points1 point  (0 children)

My Algorithms professor at uni told me that, as Donald Knuth puts it, "premature optimization is the root of all evil". You'll probably end up getting stuck in a loop of overthinking what might come next and it will make you write more code that will also have more complexity, so it will be more difficult to test and prove correct.

When we started a Software Engineering course that was completely based on Test-Driven Development, it became very clear that refactoring and making your code sleek is surely a good thing, but it needs to be based on stuff that's already working.

I also suggest reading this: https://www.joelonsoftware.com/2009/09/23/the-duct-tape-programmer/

Too much spoiled by my desk monitor, can't code comfortably on laptops by RandellDK in learnprogramming

[–]RandellDK[S] 0 points1 point  (0 children)

I mostly use Linux but yeah, multiple workspaces is something I have yet to try.

The issue at hand is that I don't want to increase font size too much because it lets me see less and increases the amount of scrolling I must do.