[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

/dpt/ - Daily Programming Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 319
Thread images: 28

File: daily programming thread2.webm (2MB, 600x338px) Image search: [Google]
daily programming thread2.webm
2MB, 600x338px
old thread: >>57652635

What are you working on, /g/?
>>
Er det mulig å lage ting med Idris?
>>
File: shift4.png (985KB, 1920x1080px) Image search: [Google]
shift4.png
985KB, 1920x1080px
>>57656992
So, I made a game some years back in windows which was a 3D version of the flash game Shift using only old opengl with primitives, the code was terrible, and now I cleaned the renderer started all over, it used to run with 60fps locked, now it runs at 400fps with Nvidia gtx 960m with open source drivers. Here's a screenshot, I may share the windows executable, not the linux version yet, cause the code is still horrible in the parts made in windows.
>>
>>57656992
some shit from this http://www.dreamincode.net/forums/topic/78802-martyr2s-mega-project-ideas-list/
working on the string length counter
>>
File: shift7.png (2MB, 1920x1080px) Image search: [Google]
shift7.png
2MB, 1920x1080px
>>57657026
>>
>>57657026
I also took the chance to implement modern opengl with shaders and shadows.
>>
Given that Scala and Clojure exist and are mature, is it time to retire Java?
>>
>>57657069
The red blocks are pushable, when you shift to the other side, they are holes
>>
File: shift8.png (2MB, 1920x1080px) Image search: [Google]
shift8.png
2MB, 1920x1080px
>>57657077
Keep forgetting to add the pics. And forgot to mention, it's made in C with only glew and SDL2 as a dependency, though I'll want to get rid of it since I only use it for threading and creating the window.
>>
>>57657075
>Scala
>Mature
Java should've been retired 10 years ago
>>
File: shift9.png (2MB, 1920x1080px) Image search: [Google]
shift9.png
2MB, 1920x1080px
>>57657089
>>
>>57657026
I'm jealous of your dedication. I can never get anywhere. I just know a lot but I sit down with opengl and get maybe half the features I want in the renderer/shader pipeline/texture upload system and then I quit.

Being able to finish something non-trivial must be nice. I'm stuck using other people's code if I want to get something done.
>>
>>57657089
nice. I made something like this, but not nearly as pretty. I got around 40FPS on my Riva TNT2
>>
>>57657109
Scala is very mature, they even fixed List(1, 2, 3).toSet() evaluating to false.
>>
>>57657089
does yours have any multiplayer?
>>
File: shift10.png (2MB, 1920x1080px) Image search: [Google]
shift10.png
2MB, 1920x1080px
>>57657115
Thanks, I'm still thinking of using the remaining FPS's for reflections and ambient occlusion, or anything else I may remember. In the original version, at the end of each level there is a door where, like in portal, you could see the next level, used stencil maps to do it, don't know if I'll do it in this version though, too much of a waste of FPS I think.
>>
listOfSonsAndNotice is an array list of sonsAndNotice,
sonsAndNotice is an object containing 2 int's, simple.. getID() returns one of those ints, and getNotice() the other int.

  
String sonsAndNoticeAsString = "sons by ID followed by their notice: ";
for(int i = 0; i<this.listOfSonsAndNotice.size(); i++) {
sonsAndNoticeAsString = (sonsAndNoticeAsString + " " + listOfSonsAndNotice.get(i).getID().toString() + " " +listOfSonsAndNotice.get(i).getNotice().toString());
}


getting an int cannot be dereferenced error here, what the fuck is up?
>inb4 im retarded
>>
>>57657167
Yeah you could profile your code and deal with it better.

I'm not aiming to insult but you'd be surprised by how some very basic optimizations can make your game go. If you just profile it and look for solutions.
>>
>>57657181
What's with your stupid variable names
>>
>>57657167
Is the source code posted anywhere?
>>
File: shift11.png (2MB, 1920x1080px) Image search: [Google]
shift11.png
2MB, 1920x1080px
>>57657161
I thought about implementing it, already am familiar with that sort of networking, though it would mean I would have to fix some things, for instance, I am generating only the walls between matter and air, and when I move a box, I am basically re creating the walls without the box, so I can have it animate between tiles, so the one moving is just a cube, only when it arrives at the grid space does it become part of the walls again, which means, if there was another player, he could be on the other side and should see a hole moving, when as it currently is, he would just see the hole disappearing and appearing a bit forward.

>>57657192
Thanks for the input, but of course I am aware of this, last week, optimizations is all I've been doing. and on the original one, I still used frustum and occlusion culling not to draw the next level when the door wasn't being seen, still, maybe there is a cheaper way of doing things.

>>57657217
As I stated above, the old parts of the code are the worst things I've ever done in my life and I wouldn't share it with anyone, that being said, maybe in two weeks or one I will have made it acceptable and I'll share it with you guys.
>>
>>57657241
Looking forward to it
>>
>>57657215
its been a long day, and I had to move fast and keep track of what things were without putting in notes.

>>57657181
I fixed it.. No need to fucking use toString() on int lol
>>
>>57657276
Also, a foreach loop will be much cleaner. Write something like this:
String sonsAndNoticeAsString = "sons by ID followed by their notice: ";
for (SonsAndNotice s : this.listOfSonsAndNotice) {
sonsAndNoticeAsString += " " + Integer.toString(s.getID()) + " "" + s.getNotice().toString());
}
>>
File: shift12.png (2MB, 1920x1080px) Image search: [Google]
shift12.png
2MB, 1920x1080px
>>57657255
If you want the windows version, it's in this link, though the initial screen is a bit bugged. It has a level creator, which I was hopping would allow for sharing the levels online, though it was never finished, and there is a login screen in the beginning which is trying to connect to something which no longer exists, making the screen lag in the menu. Beyond that, it's actually playable.
mega dot nz/#!mlgQRQKa!fftbyLQpDa45gwHw1S-9z2ogNx4kB8qeSqT3fWJoT8E
>>
File: s7.png (226KB, 1366x711px) Image search: [Google]
s7.png
226KB, 1366x711px
>>57657307
If anyone has a spare virtual machine to try it out, I too wouldn't trust executables sent by 4chan.
Pic related is from the windows old version.
>>
>>57657288
ty based anon!
>>
File: shift13.png (214KB, 1920x1080px) Image search: [Google]
shift13.png
214KB, 1920x1080px
>>57657334
This is what new code looks like.
>>
>>57657334
I'm going to see if this works with WINE
>>
>>57657392
This is what some of the old code looks like.
>>
File: shiftold.png (184KB, 1920x1080px) Image search: [Google]
shiftold.png
184KB, 1920x1080px
>>57657412
Forgot pic

>>57657404
Really doubt it.. by the way, most of the weight of the file, is just some tracks from all of the flash games, which I for some reason did not change into a compressed format...

Something I also want to do before making the code available, is maybe get rid of the Shift trademark. I talked with the original creator, he said he didn't have the rights, ArmorGames did, but that I could steer away from the style, and say it was based on the game the flash Shift was based on.
>>
>>57657450
WINE made it segfault
darn
>>
File: shift13.png (1MB, 1920x1080px) Image search: [Google]
shift13.png
1MB, 1920x1080px
>>57657477
It used to fail to run on some windows 7 machines as well, so I'm not impressed at such outcome, thanks for trying anyway!
>>
>>57657477
Maybe I'll pop over to windows and just record a walkthrough.
>>
>>57657450
what editor is that fampai?
>>
>>57657562
It's vim, I swapped computers, so the tab colors are just wrong.
>>
>>57657288
>not using StringBuilder
>>
r8 my code /g/

/**
* @param n n
* @return d on success, -1 on failure
*/
int64_t f(uint8_t n)
{
if (n <= 1) return n;
/* if n is greater than 92, fail */
if (n > 92) return -1;
n -= 2;

uint64_t a = 1, b = 1, c = 0, d = 1, e = 1, f = 0;

while (n) {
uint64_t g, h;
if (n & 1) {
g = a * d + b * e;
h = b * d + c * e;
f = b * e + c * f;
d = g;
e = h;
}
g = a * b + b * c;
a = a * a + b * b;
c = b * b + c * c;
b = g;
n >>= 1;
}

/* return d */
return d;
}
>>
>>57657589
>not using Cord
>>
>>57657591
Change the doxygen comment to be more descriptive. Why make the user aware of a local variable? Make it obvious what result it returns.
>>
>>57657631
/**
* @param n n
* @return the result on success, -1 on failure
*/
int64_t g(uint8_t n)
{
if (n <= 1) return n;
/* if n is greater than 92, fail */
if (n > 92) return -1;
n -= 2;

uint64_t a = 1, b = 1, c = 0, d = 1, e = 1, f = 0;

while (n) {
uint64_t g, h;
if (n & 1) {
g = a * d + b * e;
h = b * d + c * e;
f = b * e + c * f;
d = g;
e = h;
}
g = a * b + b * c;
a = a * a + b * b;
c = b * b + c * c;
b = g;
n >>= 1;
}

/* return d */
return d;
}
>>
File: 3mb2.webm (922KB, 1280x1024px) Image search: [Google]
3mb2.webm
922KB, 1280x1024px
>>57656992
I have a a working client for my VOIP protocol now, and I'm working on it now since I failed to sleep.
>>
>>57657642
Much better.
>>
>>57657026
very cool but
>that gamma
even if you want an edgy art style you could probably do better with tone mapping rather than just leaving the gamma untouched
>>
>>57656992
ITT: languages which sound great at first, but when you get down the rabbit hole, they're actually awful and unusable

I'll start
>haskell
>python
>go
>>
>>57657721
forgot lisp too
>>
>>57657721
Python isn't that bad, it's what I use for my VOIP client server.
>>
>>57657721
Exactly right, you should learn a practical language even if it's uncool. There's a reason Java and C# are so widely used.
>>
>>57657721
French
>>
>>57657721
>haskell
>awful
>unusable
i don't follow
>>
>>57657736
>make deals with everyone to use your shitty product
>people wanting to work learn your shitty product because everybody else uses it
>surprised when its used widely and hinders actual progress
>>
>>57657721
>>57657727
these + C# + irrelevant meme languages
>>
>>57657760
For something more than a math problem
>>
>>57657760
try doing anything IO
it will require being a category theory expert
>>
>>57657760
performance is worse than python
why should I use this crap
>>
>>57657778
no it doesn't
>>
>>57657737
>>57657721
English

>to put
>to put on
>to put off
>to put down
>to put up
>to put up to
>to put upon
>to put it to
>to putt
>>
>>57657790
by "performance is worse than python"
do you mean
"performance is worse than C"
>>
>>57657792
>hurrdurr monad transformers
>durr MONADS

monad is a meme buzzword, nobody understands it
>>
>>57657705
Thanks for the tip!

>>57657477
>>57657544
Just did a full walkthrough only to find camstudio saved only 1fps...
>>
>>57657778
do
putStrLn "I'm doing IO"
putStrLn "Holy shit"
>>
>>57657803
All of those make perfect sense
Deutsche ist doof
>>
>>57657821
see >>57657832
>>
>>57657832
but you're not
>>
>>57657821
A monad is just a monoid in the category of endofunctors, what's the problem?

Next you'll be saying you don't even understand zygohistomorphic prepromorphisms.
>>
>>57657841
Technically correct, just like in any other programming language you write code and the computer compiles and runs it and does the actual I/O.
>>
long long long long long long long long long long benis;
>>
>>57657847
Kek
>>
>>57657867
laffd
>>
>>57657847

/dpt/ users don't even understand anamorphisms/catamorphisms. You can't expect them to understand anything more technical.
>>
>>57657867
Mummy you're posting in your sleep again.
>>
>>57657832
>he thinks basic kiddo IO examples reflect real world IO
>>
>>57657806
its even worse than java
>>
>>57657893
>>actually outputting data to the console
>>ever useful in any real world context
>>
>>57657760
the only thing going for it is the nice syntax and meme constructs such as "pattern matching" or "function composition"
and maybe purity
>>
>>57657912
>meme constructs
>>
>>57657893
>implying the point was printing to the screen, not the ease of composing IO actions
>>
>>57657926
how about the packing and unpacking of data while the context of IO?
have fun with
do
t <- thing
let kill_me = whatever t >>= no_real_world_use
worst_lang = gay_balls kill_me
return (slow_performance worst_lang)
>>
>>57657932
if pattern matching is a meme, then do you never use if statements or switch cases?

>>57657965
type classes
>>
>>57657986
>everything is a meme until it becomes popular
wow
>>
1666
833.0
2500.0
1250.0
625.0
1876.0
938.0
469.0
1408.0
704.0
352.0
176.0
88.0
44.0
22.0
11.0
34.0
17.0
52.0
26.0
13.0
40.0
20.0
10.0
5.0
16.0
8.0
4.0
2.0
1.0
took this many steps 30
>>
Newbie question, is there a similar function for string::assign except for ints in c++? Im trying to edit the elements of an array from a pointer thats passed as a parameter
>>
>>57658125
This is why you learn C instead.
>>
File: 1460915899689.png (96KB, 556x430px) Image search: [Google]
1460915899689.png
96KB, 556x430px
>>57656992
I was working on a Control Template in WPF, but that fucking xaml is just so damn ugly and unreadable that I abandoned that shit.

How could I maintain an "overgrown jungle"?
>>
Trying to get webcam input through V4L2 in C++
>>
>>57658125

array[x]=whateveryouwant
>>
>>57658125

string::assign changes the size of the underlying buffer. Is this what you are trying to do?
>>
>>57658171
XAML is comfy desu, before rolling your on control template you should check thoroughly the library.
>How could I maintain an "overgrown jungle"?
MVVM, and try to re-use styles.
>>
what programming language will help me have sex with cute girls?
>>
>>57658300
javascript
>>
File: s4.png (308KB, 1366x711px) Image search: [Google]
s4.png
308KB, 1366x711px
>>57657404
Took me way too much time to record this, here it is, tell me what you think!
https://www.youtube.com/watch?v=AiLzEhxt8-8&feature=youtu.be
>>
>>57658157
I would have stayed with C to be honest but for this class and my class next semester it needs to be an object oriented language.

>>57658199
This is what I originally tried but I get incompatible assignment type 'int' to 'int[20]'.

>>57658221
Honestly im not sure, I guess my takeaway from this is is that I should probably stay off here until im more knowledgable

Thank you guys for the replies
>>
>>57658304
this isn't true!
>>
>>57658309
processing complete, finally
>>
>>57658309
>object oriented LANGUAGE
heh
(*array)[x] = whatever

learn pointers you idiot, they're easy
>>
>>57658340
>>57658309
>>57658308
Wrong reference, sorry anon.
>>
>>57658300
C, because C is like lolis: Cute, small, and never gets old.
>>
>>57658300
Haskell
>>
File: 1475807800549.jpg (103KB, 944x719px) Image search: [Google]
1475807800549.jpg
103KB, 944x719px
I just finished the BIGGEST programming assignment I ever had to do for a class

3 days nonstop dawn to dusk on my desk. My head hurts and my back aches, but it's fucking done now.

I've learned more about network programming these last few days than over all the years I've been programming in my own time, it's pretty shocking what deadlines make you do.
>>
>>57657687
Is the use of 8 bit audio a somewhat decent cutback to save bandwidth?
>>
>>57658400

All you gotta do is hop on some amphetamines and read a book, anon
>>
>>57658432
>drugs
n-no thanks
>>
>>57657901
its about the same as java
>>
>>57658309

>I should probably stay off here until I'm more knowledgeable
Nah, DPT is full of mostly novices anyways.

But regardless, it would help if we knew a bit more about what you're trying to do here, because it is possible that string::assign is not something you need an equivalent to.
>>
>>57658451

>Wanting to be sober
>>
>>57658342
This worked, thanks anon. I'll take your suggestion to heart and make out time to more properly understand them.

>>57658535
You are right, the other anon helped me out though in hindsight I should probably stay away from arrays haha
>>
>>57658570
no problem buddy
>>
>>57658308
Simple project I've made 7 years ago in flash, then ported to C opengl last year. Magnetic fields simulations.
https://www.youtube.com/watch?v=F7HTND_Uw74
>>
I want to design a programming language, where do I start? I want it to be good.
>>
>>57658601
look up programming language theory, type theory, etc
write it in haskell like all the good experimental languages are
>>
>>57658601
You need to know a lot about programming language theory and compilers. Try to find some good university courses about them.
>>
>>57658601
Depends if you want it to be fast.
First of all, flex, bison, yacc and shit.
If you wan't it to be fast, you'll need to learn assembly, even today's interpreted languages generate assembly on the fly, only deoptimizing if high level checks fail.
If you wan't it to be efficient, while having garbage collection, you have to read up on all sorts of memory management, like pooling and whatnot.
>>
>>57656992
Holy shit that's hot. Sauce?
>>
File: 1479402854763.jpg (5KB, 251x233px) Image search: [Google]
1479402854763.jpg
5KB, 251x233px
>>57658643
Why did I spell "want" as "wan't"? it's really late in here, I think I'm going to bed...
>>
>>57658652
I think it's called anime
>>
>>57658601
>>57658643
Instead of flex, bison you can also take a look at JavaCC and JTB. They're really nice tools to work with, I've used them in the past for a compilers course. They generate the ASTs and visitors for you and are generally very easy.
>>
>>57658671
Well yes... you could... if you have the particular need of wasting memory and time, to each his own I guess.
>>
>>57658643
>>57658671
>Not writing your own recursive descent parser
It's like you want to have shit error messages
>>
from >>57655485

in response to: >>57655550

couldn't get it working, even with fiddling around with the code, it just added a / to the string.

using
strrchr
did get rid of the first part, but left a / in the front.
>>
>>57658685
I guess you're right. It was just for a course so I didn't care about memory, time...only the ease and speed of development.

>>57658689
Kek
>>
>>57658342
so this is a fedora post.

im not making fun or anything, but i was finally able to hear it in my head. *adjusts collar*

*teleports behind you*
>>
>>57658731
so this is a fedora post.

im not making fun or anything, but i was finally able to hear it in my head. *adjusts collar*

*teleports behind you*
>>
>>57658710
Well, I too had a compiler class, teacher was preaching some OcaML, I had none of that nonsense and learned those tools while colleagues we're sniffing some functional. Had the best grades of that class, not because of doing it in C, but because I cared and it was something I wanted to do for a long time.
>>
>>57658781
What language will cause me to an hero sooner?
>>
>>57658827
COBOL
>>
>>57658827
Oops, didn't meant to reply to that post
>>
>>57658827
haskell
>>
I'm working on the bash user's repository
>>
Finally done.
>>
File: 1452572249761.jpg (28KB, 439x439px) Image search: [Google]
1452572249761.jpg
28KB, 439x439px
Is there a better way to find all images in my downloads folder that are 400x240 in size?

#!/bin/bash
mkdir -p bleh
for i in *
do
DIMS=$(file "$i" | cut -d ' ' -f18 | cut -d ',' -f1)
if [ "$DIMS" == "400x240" ]
then
echo "$i found"
mv $i ~/bleh/$i
fi
done
>>
>>57658866
>visual studio
>>
>>57658827
Ruby
>>
>>57658878
imagemagick.org/script/identify.php
>>
>>57658898
That'll just make you wanna use skirts.
>>
>>57658551
>being a degenerate
>>
>>57658931
?
>>
>>57658939
Lurk more, it's well know that Ruby programmers tends to be a little faggy. Glad I don't use it anymore.
>>
>>57658953
I used to use ruby, though I'm more used to python now.
>>
>>57658953
i wasn't at all surprised when I found out that our own resident tripfag Ruby senpai bought a $300 pony plushie and posts trap pics of himself on 8ch
>>
>>57658300
java because [b][i][u]ENTERPRISE QUALITY!![/u][/i][/b]
>>
>>57658962
I think Ruby is comfier than Python, but those are personal tastes.
>>57659006
Yeh, he's also bi, what a fgt! (I still like you Ruby-chan)
>>
>>57659006
Wew, I didn't know.
>>
>>57659029
I'm not a huge fan of the language, but it's been what I work with for a few months now, so it's become second nature. I haven't used ruby in a while, and I wasn't a very good programmer then, so maybe if I go back I might like it more.
>>
>>57658300
HTML and CSS because that's what's cute girls 'code' in.
>>
>>57659047
Why do all these hipster meme languages not use braces?

>inb4 muh indentation
>>
File: alwayssunny.jpg (122KB, 408x408px) Image search: [Google]
alwayssunny.jpg
122KB, 408x408px
>>57659006
>>
>>57659006
>bought a $300 pony plushie and posts trap pics of himself on 8ch
What's wrong with that anon? It's {{current year}}.
>>
>>57659068
Ehh, I don't get it either. Python's indentation based scoping is terrible.
>>
>>57659068
It's got more to do with the fact that you associate non-braceness with hipster memes. Significant whitespace is bad though.
>>
File: dada.jpg (25KB, 236x308px) Image search: [Google]
dada.jpg
25KB, 236x308px
Anyone have any major video game source code leaks? I would love to see some industry-standard C++/C code.
>>
>>57659137
I mean the half-life source is on github.
>>
>>57659157
oh where at?
>>
>>57659160
https://github.com/ValveSoftware/halflife
>>
>>57659137
Check out previous ID software games and older engines, they usually release the engine for free when they have a newer one.
>>
>>57656992
I'm going to go through the little schemer, and I'm sort of new to programming, should I do SICP afterwards? Also is cracking the code interview good for learning basic algorithms?
>>
>>57659171
>>57659182
I guess i dont have much knowledge of video game development, but... video games are essentially just engines?
>>
>>57659199
To make a program you usually make a library and then use it. To make a game you basically make an engine and then use it. Or you can use someone else's library, engine.
>>
>>57659137
Not a leak and maybe too old school for ye, but check of id Softwares open-source engines.

The engine is a true masterpiece and the way the engine handles light is IIRC supposedly still not yet totally understood, even by Carmack himself.
>>
>>57659211
when you say library... you mean API? Sorry I'm mainly a web developer
>>
>>57659195
>SICP
>Falling for /g/ maymays
lmao.
For algorithms they always recommend CLRS, I haven't read it tho. I think the one I did read was "mastering algorithms with C".
>>
How do I get into game dev? I don't know how it'll be, but I really want to at least try it once and see how it's like.
I am good in C and okay in C++, but I've never made a GUI app before, only console programs.
What do I need to learn to get into game dev? And are there any good interesting tutorials/sources?
>>
What should I do with a markov chain of /g/?
>>
>>57659223
not understood? Wow that sounds super interesting. like the code kind of had a mind of its own?
>>
>>57659227
a web dev should know how to use google
>>
could someone PLEASE explain to me, in language that a retard could understand, what exactly a `````````````blockchain''''''''''''' is?
>>
>>57659232
SDL2, just use the official docs. Abstract it how you want to after you get comfortable with it.
>>
>>57659244
ledger for digital transactions...
>>
>>57659238
Not exactly.
Its more like they tried a couple of lines of code and it just werks, without them (the brogrammers) not really knowing why.

Heres a decent video on it: https://www.youtube.com/watch?v=AwTXCmcaQNw
>>
>>57659232
Game dev makes me wanna commit sudoku, even though I'm fairly experienced with programming, it simply just have too many concepts too learn, and since I'm not a "gaymer" guy the interest is low. (Right now I'm trying Lua).
You should try SMFL or SDL, they're the most used libraries when it comes to GUI and gave dev. Also, check the lazyfoo's tutorials.
>>
>>57659255
What's so special about it?

If it's just a ledger that represents tabular data, why not just use a database?
>>
>>57659137
An old version.
https://github.com/gene9/uplink-source-code
>>
>>57659253
Thanks, I'll take a loot at it. Also, which languages are recommended for game dev? And will it be a problem if I don't have access to a windows machine (Well, I have it running as a virtual machine).
I only have Linux and OS X.
>>
>>57659266
Lazyfoo is an idiot.
>>
>>57659262
Man, her presentation style is annoying and it could be like a 90 second video.

In fact, just read the wikipedia article:

https://en.wikipedia.org/wiki/Fast_inverse_square_root
>>
>>57659199
No, many games are just the game itself, you can call it an engine if you want. What many developers do though, seen they know they'll want to make more games, is combine all of the code that may be the same across all of their games, like all of the rendering techniques and entity component logic. Instead of doing it all over again, they separate those parts of the code, making it agnostic to the specifics of said game, then they use those tools to make the game proper.
>>
>>57659289
SDL2 has some bindings to langs other than C, and obviously also works in C++. Use the language you are most comfortable with.
>>
>>57659267
because it uses "gas" and the bitcoin encryption scheme. Which is a very durable scheme.
>>
>>57659231
Some memes are worth falling for, anon.
>>
>>57659292
Thx, good read
>>
>>57659266
Lazyfoo's tutorials are really outdated though.
>>
File: 1420763526695.jpg (20KB, 249x249px) Image search: [Google]
1420763526695.jpg
20KB, 249x249px
why the FUCK doesn't recv() block until it receives the amount of data I tell it to get?

why the FUCK can send() and recv() return with less data than I told them to get?

I understand recv() returning zero if the connection closed, but why else would you return anything less than the expected amount?
>>
>>57659306
And about the OS?
>>
>>57659292
I, personally, enjoy it. Sometimes you need the flavor in material. rather than reading rich text
>>
>>57659320
read(2)
>>
>>57659309
Sorry, I have no clue what you're talking about.

Would you be able to recommend any books or tutorials on the subject that I could read up on without any prior knowledge of the subject?
>>
>>57659325
Literally doesn't matter as long as what you write is OS agnostic, which it will be if you're not an idiot, but you seem to be. Just don't use POSIX stuff and you're fine.
>>
Why don't you use TempleOS /g/? It just works.
>>
>>57659267
Part of the "magic" of the blockchain is the permanence-enforcing involved in the hashing; each block's (blocks hold some number of discrete transactions) hash is dependent on the hash of the block before it. This lets you say "these are the changes since time t" and be confident in the statement. It sort of lets you build/update a ledger in the same way you build/update a git repo. You get the correctness checking, but get to distribute/update/modify your ledger in the form of diffs.


That said, a lot of what's going around industry in blockchain hype is stupid bullshit. The financial services industry wants to use blockchain because they like the buzzword, but they want to be able to revoke/modify transactions after-the-fact, completely defeating the value of a blockchain (at least as far as I understand it)
>>
>>57659335
>It is not an error if this number is smaller than the number of bytes requested; this may happen for example because fewer bytes are actually available right now

Then why doesn't it just block until there is enough data god damn

Or is this some kind of way to appease people who unironically thing variable-length protocols are good
>>
>>57659302
Awesome explanation. Makes sense.... but lets say... N64's Ocarina of Time. Would a console game pre 2000s have many engines to work with? Or do we only see engines with big companies like Valve
>>
>>57659262
>click tech-related video
>woman starts talking
>close video

I can't be the only one.
>>
>>57659369
It does block, you're using recv, not read.
>>
>>57659366
I see, thanks. That makes a lot of sense
>>
>>57659341
My bad. hmm... I'd say look at this? http://www.blockchaintechnologies.com/blockchain-definition I learned it a corporate event.
>>
>>57659383
I'm almost certain that recv can also return with less data than requested.
>>
>>57659373
a sexist? No you're not the only. But doesnt make it right.
>>
>>57659373
Then youre retarded and need to learn some computer-history.
>>
>>57659373
Same

I tried watching this one but quit halfway through.

Why can't wimmin present a topic properly?
What's so hard about just talking normally and actually making an effort to convey information?
>>
>>57659370
There's loads of engines, for example, follow Anki on twitter, which is just one guy making an engine. There's Panda3D which is developed on github. I made an engine with a small group of friends in C++ for windows/linux/mobile. There's also some tutorials on youtube of bennybox I think his name was, who goes through many of game engine concepts while coding his own engine. Just as a heads up, it's fun to learn these things, but game engines nowadays are so complex and have so many different and huge modules, which do require large teams to develop and maintain. Advances and optimizations are always being published on papers, and to apply them all is a lot of work. Btw, check out the posts in the top of this thread about the Shift3D game which I am developing.
>>
>>57659429
...sexist
>>
>>57659407
>>57659416
>>57659461
I've never watched a tech video worth my time that was narrated by a woman.

This isn't even sexism, they just never go in depth, the treatment of a topic is always entry-level at best.
The worst part is that they're almost always 10 minutes long, and yet they impart almost no information.
I could learn more reading a massively oversimplified Simple English wikipedia article, this is ridiculous.

>>57659416
No, I suggest you learn your computer history, and not the feminist narrative being pushed in the last 10 years.
>>
>>57659461
fuck off klossy
>>
pajeets are better than women at coding
>>
>>57659494
who said pajeets are bad at coding?
>>
>>57659429
>cant watch vid of woman without consciously adressing it
>uncomfortable with women
>sexually and socially inexperienced
>>
>>57659485
whos klossy?
>>
"You shouldn't use a linked list there."
"Okay I'll use an array implementation of linked list"
Pajeets are funny guys.
>>
Anyone know any good programming youtubers to follow?
>>
>>57659510
>sexism
>projection
>virgin shaming

you can pretty much always tell when a woman replies to you
>>
>>57659542
???
>>
>>57659510

>can't read an opposing opinion without conciously addressing it
>uncomfortable with common sense
>sexually and socially inexperienced

nice projections, kid
really made me think
>>
>>57659482
>they just never go in depth

This is the true hallmark of a retard.
Cant you see the obvious moronic nature of such an absolute general statement?

I am dead sure that there are women going in depth (whatever that means) right this very second.

>and yet they almost always

What the fuck does that mean, anon?
Always? In what context? what always? What the fuck are you talking about?

Computer history is not based on "muh feminist-narrative" its HISTORY, its well-documented, its factual knowledge as much as any other knowledge.

Such brainlets on the chans these days.
>>
>>57659542
there are none
video is a terrible format for disseminating programming tutorials
>>
>>57659546
i wish i was still a closet weeb that could fap to 2d girls
bitches aint worth it friends
>>
>>57659536
Not a bad idea, the virtues of cache locality are lost on too many.
>>
>>57659262
She's pretty wrong on loads of shit in there, the evil part isn't the bitwise shift, it's casting a float as a long, which is undefined behaviour. And she said they didn't know where the number came from, the team didn't, carmack did. The game does not calculate every light particle, that is absurd. The game does not calculate where all the light will go when it reflects on the rocket launcher, that is also absurd...
>>
>>57659572
Did you even read the post friendo
>>
>>57659546
>hit a nerve
>>
>>57659576
not really it's 4am
>>
>>57659562
not tutorials you dimwit.... theories and concepts
>>
>>57659575
Sure, that is completely fair. I am a huge noob so i would not now, i just love Quake (i posted the vid)
>>
>>57659585
>>57659560
Can you women learn to argue effectively?
Personal attacks are no way to respond to criticism that isn't even directed toward you personally.
>>
>>57659503
/g/
>>
>>57659597
if you want to masturbate just do it
>>
why do all lisp programmers have such crippling aspergers? having a conversation with them feels like pulling teeth. they worry about everything that doesn't matter and stubbornly insist that they're right about everything
>>
>>57659609
wut?
>>
File: bjarne.png (51KB, 971x644px) Image search: [Google]
bjarne.png
51KB, 971x644px
>>57659536
>>57659572
>>57659576
pic

>>57659598
To be fair, the video does seem to be trying to appeal to a less technical audience, maybe even children, so maybe it's unfair of me to judge it otherwise.
>>
>>57659603
I am not a woman!
As to wether they can argue effectively, they seem to differ in ability.

As do us /b/ros, amirite? rite?!?

For you id like to consider the fact that you have a limited time on this Earth and that chicks are alot cooler to fuck and smoke weed with, as opposed to shy away and ailienate yourself from.

And this is fucking 4chan you triggered little cuck.
Yer going to get some shit thrown your way when you act all pussylike
>>
>>57659625
I don't understand. If you want to insert an element in the beginning, won't a list be far superior?
>>
>>57659625
I know that vectors are better than linked lists, that's not the point.

The point is "Array implementation of linked list" makes no sense. This pajeet learned the definitions of these two things in an OOP setting and now all he knows is OOP.
>>
>>57659642
Not if you want to store multiple elements at the beginning.

You may have to go to memory to store the first one, but most of the others would just hit some layer of cache.
>>
>>57659643
Like in the pic, you could be a little bit more charitable, and assume he's talking of preallocated linked list.
>>57659642
Yes, though this is a benchmark for random insertions, and on average, vectors are much quicker. What many people fail to realize is that the CPU is great at moving large blocks of memory around, if you insert at the beginning of a vector, but instead of shifting the elements one by one, use a single memmove ore memcpy instruction, it will be not much slower than the two pointers you have to change in the linked list.
>>
>>57659676
I wouldn't be that charitable. He never heard of a vector before I mentioned it to him.
>>
>>57659536
>Pajeets are funny guys.
My masters program is like 70% pajeets.

They all cheat off each other. They all look incredibly nervous when asked any question.
>>
>>57659656
I still don't understand, sorry I'm new to programming.
The point is, you really can't insert an element at the beginning of a vector, unless you shift all the elements by 1 to the right and then insert. So won't a linked list be better here? Please correct me if I'm wrong.
>>
>>57659643
Maybe my mind is fucked after a lot of OOP stuff, but it makes perfect sense to me.

An "array" is a compound data structure, with the requirement that each data value is the same size and are stored contiguously in memory.

A "linked list" is an abstract type in which abstract elements directly reference one another.

It makes perfect sense to back a linked list with an array, versus a dynamically allocated structure in heap memory.

Similarly, you could have a map structure that is backed by an array or a map structure backed with a dynamically allocated linked list or a map structure backed by a hash table and so on.

Data structures are fundamentally separated from abstract data types.
>>
Functional programming has Got to GO!
#NotmyParadigm
Love Functional Programming Hate.
>>
>>57659676
>What many people fail to realize is that the CPU is great at moving large blocks of memory around
Oh, that's interesting. Never knew about it, thanks. How is memmove actually implemented and why is it faster than shifting the elements one by one? Wouldn't memmove also copy the memory chunk one byte at a time?
>>
>>57659689
AFAIK most implementations will shift it over by a bunch of memory at a time and not just one space.

Example:
>your vector has an array of length 10 and stores 10 elements
>you add another
>now it has to store 11 elements

Instead of moving around everything to get that one more space, it will more around everything a lot more and get, say, 10 more spaces, with some of that space put at the beginning. Now you can add more data to the front in constant time, until the next realloc.
>>
>>57659730
Oh, I knew that they usually double the size of the vector if you add it at the end. Makes sense to do the same if you add it in the front too.
So if you have a vector <int> v, and you insert something in the front, won't v become (v-1) according to you.
That can create some problems, I reckon.
>>
>>57659682
Fair enough.
>>57659717
No, there are buses, which bring large chunks of memory, memmove interfaces with the kernel, which is the part that is aware of the hardware and knows all of the instructions it can perform. By the way, even if you're programing in bytes, you're probably just slowing down your processing, because your CPU is most likely 64bit which means each operation is performed on way larger buffers than needed, and the CPU has to add extra operations to stop the results from overflowing that single byte. You should read up on newer ram tech, if your computer was working in single bytes, you would not be able to run anything in your lifetime.
>>
>>57659757
Not necessarily. The backing array just has to be there in some form, and the vector structure just can abstract away those kinds of details as it sees fit.

When I create a vector and tell it to store something at position zero, I don't know if it has a backing array of size 10 and it stores the value at index zero, or if it has a backing array of size 100 and it decides to store the value at index 25, leaving the previous 0-24 empty for adding stuff to the front in the future.

As a programmer using a black-box interface, you don't know about those details.
>>
>>57659761
Thanks, didn't know about all this stuff. I guess this is what happens when you only think in terms of asymptotic time complexities and don't know shit about computer organisation.
>>
>>57659781
And that's how most people normally think, I recommend you to watch this full lecture, if you don't have time, just watch this part.
https://www.youtube.com/watch?v=YQs6IC-vgmo
It's by Bjarne Stroustrup, the creator of C++. He is an engeneer, and at some point, someone in the audience tells him he shouldn't think in terms of hardware, because hardware changes, and mathematics doesn't, which is silly, because C++ doesn't run on air mathematics, but on hardware...
>>
I've just made this: http://korbo.ga/
Let's draw together :^)
>>
>>57659761
Not him, but is this the reason why C compilers typically insert padding between the elements in a struct?
>>
>>57659822
It's a part of it, another is for the data to be aligned on powers of two, which makes accessing them quicker. When you access a member of a structure in C, some calculations have to be made in order to arrive at the correct address, if they are aligned to powers of two, these calculations are much faster. If you're not only using the structure alone, but have it as a contiguous array, the assembly for that is 'lea' which has to make multiplications by the size of the structure, again, same issue.
>>
File: korbo.ga.png (1005KB, 1294x1272px) Image search: [Google]
korbo.ga.png
1005KB, 1294x1272px
>>57659800
I made this :^)
>>
>>57659799
What a great lecture by Scrooge Mcduck.
>>
I'm using Poweshell 2.0 because work.
Turns out $null is iterable! And it was a deliberate design choice!

At least they changed this in 3.0 and up.
>>
>>57659697
Doesn't solve the issue however. Because it's the pointer dereference that causes the cache misses.
Even if you're doing something clever where you have a chunked linked list (say you only point between every 5 elements so you can add/remove 5 elements at a time) you would still be slower. You just divided the penalty by 5 at best.

And for pajeets: It's not a virtue of std::vector. It's a virtue of arrays.
>>
>>57659884
Haha pajeet. In western culture that's a symbol of hate not peace.
>>
>>57659799
Interesting comment on youtube:
> For this example, both structures take Theta(n^2) time. No matter his claim, this is NOT an example where Linked Lists should thrive. ... There are certainly simple examples where Vectors will take Theta(n^2) while LinkedLists will take Theta(n).

Thoughts?
>>
>>57659799
Stroustrop is generally a terrible person who's in charge of a terrible committee that does terrible things.

But this is one of the first talks he got right. It's like an admission of failure.
>>
File: pepe-rare.gif (359KB, 640x636px) Image search: [Google]
pepe-rare.gif
359KB, 640x636px
>>57660009
This is a real hate symbol
>>
>>57660018
>There are certainly simple examples where Vectors will take Theta(n^2) while LinkedLists will take Theta(n)
like what?
>>
File: 7 (3).jpg (107KB, 1920x1080px) Image search: [Google]
7 (3).jpg
107KB, 1920x1080px
Repeating code is ok if it makes it easier for me to keep track of things, right, lads? Please say yes.

function telegraph(n) {
return new Promise((resolve, reject) => {
get("http://www.telegraph.co.uk/news/politics/").then((body) => {
let $ = cheerio.load(body);
let links = $("article .list-of-entities__item-body-headline a");
let linkArr = [];

links.each((index, elem) => {
let href = "https://www.telegraph.co.uk" + elem.attribs.href;
let data = elem.children[0].data || elem.children[1].data;
let html = `<span class='quote'>&gt;${data}</span><br><a href="${href}">${href}</a><br><br>`

linkArr.push(html);
});

n = n || linkArr.length;
resolve(linkArr.slice(0, n));

}).catch((e) => {
reject(e);
});
});
}

function express(n) {
return new Promise((resolve, reject) => {
get("http://www.express.co.uk/news/politics").then((body) => {
let $ = cheerio.load(body);
let links = $(".section-container a");
let linkArr = [];

links.not("[rel='nofollow']").each((index, elem) => {
let href = "https://www.express.co.uk" + elem.attribs.href;
let data = elem.children[3].children[0].data;
let html = `<span class='quote'>&gt;${data}</span><br><a href="${href}">${href}</a><br><br>`

linkArr.push(html);

});

n = n || linkArr.length;
resolve(linkArr.slice(0, n));

}).catch((e) => {
reject(e);
});
});
}


I have a few functions like this for a variety of different sites.
>>
>>57660072
He hasn't mentioned any, but maybe inserting something just after the first element?
>>
>>57660085
>Repeating code is ok if it makes it easier for me to keep track of things, right, lads?
It depends, but in the general case: no.
>>
>>57660085
nice bait
>>
>>57660085
Yeah, the degree of repetition vs difference here means you're probably on the right track, at least assuming there aren't a further 50 function guardian(n) and function sun(n) and function daily_mail(n) etc etc etc.
>>
>>57660091
for a vector it's still only O(n) to move each element to make room for the inserted element
>>
>>57660091
Arrays will probably win due to the cache.
>>
>>57660106 here
it also depends whether this code is like a personal hack project or something that you're being paid to write and someone else will be paid to maintain.

Because that code looks fragile as fuck.
>>
>>57660107
No, you're inserting n different elements, so for a vector it'll be O(n^2).
But each insertion for a linked list will take O(1), so total would be O(n)

>>57660108
>Arrays will probably win due to the cache.
It'd be nice if someone benchmarked it. I'm too lazy to do it though.
>>
>>57660018
Well provide a situation where linked lists thrive then.
The problem with a linked list is that it will always have trouble with any sort of iteration. Unless you're always just dealing with the first element or last element (in which case you should really just use a stack or similar structure) vectors win. Because the penalty on iterating is just huge.

The use case for a linked list is so small it shouldn't really be considered in any performance critical portion of code.

It's only really fine to use it in situations where the element count is really small, it fits the use case well (iteration being less common than removal/insertion) and you can spare the memory. And even then why do you use it? It's for convenience. You find that it's more convenient to use a linked list for some reason. Its really only decent when you have multiple chains running through it. Say 50. That's certainly more than one cacheline but the CPU can predict where you will go if you only follow a chain at a time. So you don't take as much of a penalty. Doing multiple chains in a vector require multiple sets of indices stored separately. And updating those is a pain, requires you to search all 50 sets and remove any mentions of the index you had.

But the linked list still fucks up the cache for the rest of the program though so that's worth considering.

Overall. If you have a habit of considering a linked list just stop. Wherever you'd use one if you just default to vector your life is easier. It's one less thing to think about. Just like how you'd never use the standard implementation of map.
>>
>>57660126
that would be moving m different elements and inserting n different elements. O(m + n) = O(n)
>>
>>57659320

Like read(), fread(), fgets(), and pretty much any other function in C or POSIX APIs associated with reading from input, the size argument does not exist to tell how much you WANT to receive, but rather, the size of the buffer it is being read into. This value is used to define the MAXIMUM AMOUNT of data you can receive. If there is not enough data to read, it is still possible, and indeed highly likely, that the user wants to do something with the data received.

In most cases, the programmer does not know the exact amount of data they are going to read. They do know, however, the amount they can accept.

>>57659369

>Or is this some kind of way to appease people who unironically thing variable-length protocols are good

Not only are they good, they are an absolute necessity. Suppose I want to read a 4chan post. I know that it can be anywhere between 1 and 2000 characters. There are thus at least 2000 different lengths of data that could be received by the server. If recv were limited to always block until it receives an exact number of bytes, then 4chan would have to pad each post to equal the exact amount received by the server. Moreover, it would be possible to create a denial of service attack by opening up multiple connections, each of which sending less data than required.
>>
>>57660144
You're assuming that the sequence of elements to be inserted is already known to you, but it's not.
Suppose you get only one element at a time, then vector will be O(n^2) and Linked list will be O(n)
>>
>>57660085
Anything is OK if it makes it easier for you.
The situations where you should refractor code into reusable parts tend to come naturally. Because when it becomes a bother is when you should do it.
>>
People using big-O notation.
It's irrelevant here because the linked list always wins in your arbitrary standard shit show.
Vector wins in the real world.

If memory access becomes instant that's different.
>>
>>57660144
>O(m + n) = O(n)
I'm not even following what you were arguing about, but that is wrong.
>>
Make sure to spend some time with your family on thanksgiving!
>>
>>57660207
Go home, 'shart-in-mart'er
>>
Does anyone else stop brushing their teeth because it feels uncomfortable when you haven't for a while? Like maybe 6 hours after.

They're fine anyways. 5 years and no issues if I take 3 weeks to prepare for doctors appointments. It was a little bit awkward before but now it works just fine. I also got a good insurance which cost less than 10$ a year so that's fine.
>>
>>57658652
Hime goto. Short and kinda boring.
>>
>>57660228
literally what board was this meant for?
we don't have a health board anymore
>>
>>57656992
>kernel shouldn't pack the struct
Depends.
If it unpacks it on use its fine.
>>
File: himegoto-tsukudani-norio-4447639.jpg (207KB, 728x1072px) Image search: [Google]
himegoto-tsukudani-norio-4447639.jpg
207KB, 728x1072px
>>57660236
the manga is much better and more fulfilling
it's 6 volumes, so it's short but not 5 minutes short

also it gets super steamy
>>
>>57660273
>Literal fag shit
>>
>>57660253
Oops sorry it was for my Skype group.
>>
Messed up the code tags

How do I represent a graph in an adjacency list in C++?

I have to store some information for each node, so I made the following struct
struct Node {
int id;
string name;
// Some for fields
};


Now, do I make a vector of vector of pointers to Node? Is there any way I can avoid using pointers?

vector< pair<Node, vector<Node *> > > adjlist;



It's basically a list of of pairs, so the following graph

V1-V2
|
V3



would be represented like this

(V1, [&V2, &V3])
(V2, [&V1])
(V3, [&V1])


This is for a competitive programming problem so I really don't care about software engineering factors like maintainability, readability, etc. I just want simple fast and efficient code.
>>
>>57660196

Big O is not irrelevant, but it is important to note its weaknesses when assessing the performance of an algorithm/data structure. Namely: it can only consider the growth rate of time cost, and does not take into account constant factors at all. Depending on the scenario, constant time expenses of individual operations may overshadow the increased number of operations from the greater computational complexity. L3 cache misses are rather expensive operations, as are page faults. Algorithms that regularly access memory addresses that are distant from each other will run into both of these regularly, and it will severely impact their performance.
>>
how do packet sniffers detect where one packet ends and another starts?
>>
>>57660308
every packet has it's length written at the start and every packet has a header, you can tell when you're reading a new packet, it stands to reason that the old packet is completed
>>
>>57660306

Are you the person he's talking about
>>57659006
>>
>>57660308
It's the job of the physical layer (i.e. your network card) to decide where a packet begins and ends. Any software above it is just going to see individual packets.
The packet headers will say how long it is.
>>
>>57660316
>>57660324
right, but lets say you are using sockets
all that info is already abstracted away when you call recv since you specify the amount of bytes you want to read right?
even if those bytes came in different packets
>>
>>57660290
Make two vectors and remove/add elements in pairs.
Can even just write a wrapper for it if you like.
Simple, fast and does what you need.
>>57660306
>constant factors
Yeah. The thing is that the factor of ~200 on every access is just too big for this linked-list case in the thread so it shouldn't be used at all.
>distant memory
Avoid expressing it like this. When you're dealing with a cache line size it's not about how distant memory is its about how it's not tightly packed or predictable. The 'distant memory' bit makes it sound to people like you could just push a linked list into the same allocated block and it would be fine. The CPU still (probably) has problems following the pointers. It's not really about how distant it is.
>>
>>57660305
Can anyone help me please?
>>
>>57660344
When using a TCP connection, all of the information about individual packets is abstracted away. It will appear as a bi-directional byte stream to the software that uses it.
If you're using UDP, will will receive it as individual packets.
>>
>>57660319
He is talking about me. I do have a plushie that I commissioned for a bit over $200. I don't post trap pics though. I'm a neckbeard with hairy legs and a somewhat hairy chest.
>>
>>57660373
>over $200
why?
>>
>>57660370
It's been less than 10 minutes since you posted that.
Chill the fuck out. You're not entitled to an answer.
Someone will reply to you if and when they feel like it.
>>
>>57660370
Didn't link right.
>>57660369
Is a response.
>>57660379
Well he's probably a grownup with disposable income. He can spend it as he chooses.
>>
>>57660369
So you're saying that I just keep a long list of the edges? I didn't understand it fully.
So, for the same graph, my vectors would be
[V1, V1, V2]
[V2, V3, V3]

And wouldn't I still need to store the pointers to the vertices in the vector because if I change some field in V1, it should be reflected everywhere there is V1.
>>
oh jesus fuck i broke something
https://a.pomf.cat/xmbfpo.ogg
>>
>>57660379

Materials alone cost $50.

Plush was custom made, and therefore labor had to be expended to create a pattern before the individual pieces could be made and sewn together. It was also made in the US, so I was paying $7.58 per hour of work. All of this makes the price significantly higher than a plush you might find in the store, which uses a pattern that is used repeatedly (allowing the cost of its design to be spread out over the number of plushes sold), cheap materials, and cheap Chinese slave labor.

It is also worth noting that the eyes and butt mark were embroidered, so it was not simply a matter of cutting out a bunch of minky fabric, stuffing it, and stitching it all together.
>>
>>57660457
https://a.pomf.cat/pjmvvr.ogg
something is very wrong, rip adrenaline junkie
>>
>>57660442
Maybe I'm misunderstanding the problem. Ignore it if it doesn't make sense.
>>
>>57660442
Why are you worried about storing pointers, exactly?

At the end of the day, you're gonna need to access memory at some point, and if you want to refer to the same node in more than one place, it's gonna be through a pointer at least some of the time.

The alternative is deep copying and O(n) updates where n is the number of copies a given node (for each node, maintain a list of pointers to copies of it. When you update a node, update each copy). This might make sense if you're spending a ton of time traversing the nodes and not really changing them often.
>>
>>57660457
>>57660472
What are you even trying to do?
>>
Updated with undo support (CTRL + z)
http://korbo.ga/
>>
>>57660487
I guess you're right, pointers are the way to go.

>The alternative is deep copying and O(n) updates.
No that would be too expensive for me since I'm implementing Dijkstra's algorithm and it was a lot of distance estimate updates.
>>
>>57660494
i'm recording from a monitor of my main device to put into a loopback device using a version of my voip client, then recording from audacity, which gives earrape and nightmare fuel. basically OpenAL fucked up.
>>
>>57660487
To be clear, that'd be a

vector< pair<Node, vector<Node> > > adjlist;
vector<vector<Node *> > nodecopies;


and updating the contents of nodecopies[m] when node m is updated

This might actually be marginally faster in the following scenarios:

-updating nodes is MUCH rarer than reading them
-memory reads are VERY expensive

>>57660514
>Dijkstra's algorithm
yeah, adjacency list of pointers sounds like what you want. It's not perfect because you need to read a pointer and then read the actual node, but I don't think there's really an alternative.
>>
template<class K, class D>
D& BTItr<K,D>::operator*(){
return node->data;
}


why the fuck am I getting invalid initialization of non-const reference? I'm returnign a reference to member variable
>>
Why are you up this late in the night /g/?
>>
>>57660703
It's only 10:30pm.
That's not very late.
>>
>>57660708
am
>>
>>57660703
but its only 8pm here....
what do you mean by "night"
what kind of retardation is this?
>>
new thread >>57660748
new thread >>57660748
new thread >>57660748
new thread >>57660748
>>
Can I ask a question.
import random
suits = ["spades", "diamonds", "clubs", "hearts",]
Ace, Jack, Queen, King = 11, 10, 10, 10
cards = [Ace, 2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, King]
playerScore = 0
dealerScore = 0

def scoreCompare():
print "dealer has a total of " + str(dealerScore)
if playerScore > dealerScore:
print "you win!"
elif playerScore < dealerScore:
print "you lose!"
else:
print "it's a tie!"

card1 = random.choice(cards)
cards.pop(cards.index(card1))
card2 = random.choice(cards)
cards.pop(cards.index(card2))
playerScore += card1 + card2
print "You have " + str(playerScore)

dealerCard1 = random.choice(cards)
cards.pop(cards.index(dealerCard1))
dealerCard2 = random.choice(cards)
cards.pop(cards.index(dealerCard2))
dealerScore += dealerCard1 + dealerCard2
print "dealer has " + str(dealerCard1)

def hitMe(cardDrawer):
newCard = random.choice(cards)
cards.pop(cards.index(newCard))
cardDrawer += newCard

while True:
if playerScore > 21:
print "You bust! You lose!"
break
answer = raw_input("will you hit or stay? ")
if answer == "hit":
hitMe(playerScore)
print playerScore
elif answer == "stay":
break

while True:
if dealerScore < 17:
hitMe(dealerScore)
elif dealerScore > 21:
print "Dealer busts! You win by default."
break
elif dealerScore >= 17:
scoreCompare()
break

print cards
raw_input()

Somehow my script is trying to use a list index that is outside of the possible range. I thought my code would only ever pop on an index of an existing item in my list.
>>
>>57660753

Honestly, rather than pulling random elements out of the list, thus forcing every other element to be shifted into place, why not shuffle the list and start pulling elements off the end? This also has the added benefit of not having to deal with wrong index bugs.
>>
>>57660814
>why not shuffle the list and start pulling elements off the end?
because I didn't even know the shuffle function existed. Thanks for pointing that out. Although, I am still curious as to why I'm getting that
bug to begin with. I thought my code would pick a random item, look at its index value, and then pop it using that number. How is it getting values outside of the list range?
>>
>>57660926

>How is it getting values outside of the list range?
Not a clue, and I'd rather not go about debugging index errors.
>>
>>57661041
I see. Thanks for your help regardless.
>>
>>57660018
This is the problem though, you're talking about complexity on a problem where complexity does not matter, it's like the difference between an algorithm that in terms of complexity should be twice as slower, but that can be run in separate threads making it faster than the one with simpler complexity.
>>
>>57660753
Your hitMe function doesn't actually change the score.
Thread posts: 319
Thread images: 28


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.