• What are you working on? v16
    5,004 replies, posted
[QUOTE=polkm;28716660]Jimmy Hendricks[/QUOTE] :buddy:
What would be the best way to handle 2k tcp connections? I was thinking I would just setup a connectionless socket system cause I have no idea how I would receive on 2k connected sockets. Also what would be the best way to handle connectionless sockest? Send a connect packet and then return a unique id and use that for finding out what packet is from who?
[QUOTE=high;28721060]What would be the best way to handle 2k tcp connections? I was thinking I would just setup a connectionless socket system cause I have no idea how I would receive on 2k connected sockets.[/QUOTE] Use poll() instead of select(), use threads only for parallelism (as opposed to concurrency), and tune the sockets' buffer size. 2000 connections is not really a difficult problem. [QUOTE=high;28721060]Also what would be the best way to handle connectionless sockest? Send a connect packet and then return a unique id and use that for finding out what packet is from who?[/QUOTE] When receiving a datagram you're given the address of the remote end-point. You probably want to use it in conjunction with a custom ID field. Keep in mind that if you want to do transactions like the above connect packet, you need to implement some level of transmission reliability, which UDP does not offer.
[media]http://www.youtube.com/watch?v=RdfR72mW4Pg[/media] THREAT CONTAINED. I also added pause/resume functionality, mapped to the "P" key by default.
I've been doing work on my scripting language again and was wondering; how do you implement functions? I really don't know how it is supposed to work, and wikipedia/google have failed me.
[QUOTE=jA_cOp;28721712]Use poll() instead of select(), use threads only for parallelism (as opposed to concurrency), and tune the sockets' buffer size. 2000 connections is not really a difficult problem. When receiving a datagram you're given the address of the remote end-point. You probably want to use it in conjunction with a custom ID field. Keep in mind that if you want to do transactions like the above connect packet, you need to implement some level of transmission reliability, which UDP does not offer.[/QUOTE] So something like have 1 thread that loops through the connections checking if they have data and if they do read it into buffers. Then have a few threads that process the buffers?
[QUOTE=high;28722817]So something like have 1 thread that loops through the connections checking if they have data and if they do read it into buffers. Then have a few threads that process the buffers?[/QUOTE] Yeah, you could do that. Don't bother creating more threads than cores on the machine though (except for an acceptable minimum of two due to the socket thread), although it also depends on exactly what those threads do.
[QUOTE=high;28721060]What would be the best way to handle 2k tcp connections? I was thinking I would just setup a connectionless socket system cause I have no idea how I would receive on 2k connected sockets. Also what would be the best way to handle connectionless sockest? Send a connect packet and then return a unique id and use that for finding out what packet is from who?[/QUOTE] Don't reinvent the wheel, just go use something like node.js
[img]http://i55.tinypic.com/fjhhs1.png[/img] whackin a dude with a bat [editline]21st March 2011[/editline] cause he stole a pair of my underwear.
[QUOTE=polkm;28716660] in other other news, esalaka I was listening to your last.fm and it was good (Jimmy Hendricks) then out of fucking no where ... [img_thumb]http://f.anyhub.net/2dWQ[/img_thumb] I guess there is nothing wrong with it, I just think its a unusual combination.[/QUOTE] It's hilarious to listen to on the occasion. And I have automatic scrobbling on in Spotify. Hence. Also, I'm surprised it played Jimi Hendrix, I actually listen to other stuff quite a lot more.
I decided to start at this again. This time, I'm going to do it properly. [img]http://f.anyhub.net/2eiK[/img]
my latest software-dev-course assignment: "You are working in a team of software developers on a new application to help to [b]manage the process of recording marks for modules at universities.[/b]" jesus fuck this is possibly the most unimaginative, boring assignment they could've given us ): the last one was "make an application that makes it easier to create comic strips, preferably with a drag-and-drop interface"... but this? urghh... no motivation to do this... ps anyone doing a software development related course, or working - does the mantra of "write a test class for EVERYTHING" really happen in the real world? I keep losing marks for not using a single test class whilst developing applications - I mean like this: [code]SomeJavaMathClass { public static int returnsANumber() { return aNumber; } } TestSomeJavaMathClass { public void test() { int x = SomeJavaMathClass.returnsANumber(); assert x == aNumber; } } ...[/code] Because that code can fuck off, I'm quite happy using print() or a debugger to catch bugs in my program. Writing test classes for ~~EVERYTHING~~ seems like a complete waste of time. FUCK this module. /rant
[QUOTE=TehDoomCat;28726441]ps anyone doing a software development related course, or working - does the mantra of "write a test class for EVERYTHING" really happen in the real world? I keep losing marks for not using a single test class whilst developing applications - I mean like this: [code]SomeJavaMathClass { public static int returnsANumber() { return aNumber; } } TestSomeJavaMathClass { public void test() { int x = SomeJavaMathClass.returnsANumber(); assert x == aNumber; } } ...[/code] Because that code can fuck off, I'm quite happy using print() or a debugger to catch bugs in my program. Writing test classes for ~~EVERYTHING~~ seems like a complete waste of time. FUCK this module. /rant[/QUOTE] I think test-cases are incredibly useful. I used to do what you did - just have print statements about the place, maybe an assert or two if it was an exceptional circumstance, but for the most part I'd just ignore or avoid any errors that occurred. When I started dealing with projects that needed some more rigorous error checking, I'd start running tests on all the modules - but that meant rewriting a lot of the same code. So it was basically an incredible epiphany when I realised how simple yet powerful unit testing was. I'm not sure about in other languages, but in C# using NUnit it's fantastic to just click the "run all tests" button and see that everything that you expect to happen, does happen. Running with code coverage is even better - you can see exactly how much of your code is being processed and run through in your tests, so hidden bugs can usually be caught out here or code removed if it's never going to be accessed. Unfortunately, due to the non-deterministic nature of a lot of programming there'll still be edge cases and things where bugs occur and you haven't caught them with unit-testing or code coverage, but those two tools will certainly help reduce the likelihood.
[QUOTE=TehDoomCat;28726441]my latest software-dev-course assignment: "You are working in a team of software developers on a new application to help to [b]manage the process of recording marks for modules at universities.[/b]" jesus fuck this is possibly the most unimaginative, boring assignment they could've given us ): the last one was "make an application that makes it easier to create comic strips, preferably with a drag-and-drop interface"... but this? urghh... no motivation to do this... ps anyone doing a software development related course, or working - does the mantra of "write a test class for EVERYTHING" really happen in the real world? I keep losing marks for not using a single test class whilst developing applications - I mean like this: [code]SomeJavaMathClass { public static int returnsANumber() { return aNumber; } } TestSomeJavaMathClass { public void test() { int x = SomeJavaMathClass.returnsANumber(); assert x == aNumber; } } ...[/code] Because that code can fuck off, I'm quite happy using print() or a debugger to catch bugs in my program. Writing test classes for ~~EVERYTHING~~ seems like a complete waste of time. FUCK this module. /rant[/QUOTE] I think you misunderstand the purpose of unit testing. [url]http://en.wikipedia.org/wiki/Test-driven_development[/url]
[QUOTE=mechanarchy;28726754]I think test-cases are incredibly useful. I used to do what you did - just have print statements about the place, maybe an assert or two if it was an exceptional circumstance, but for the most part I'd just ignore or avoid any errors that occurred. When I started dealing with projects that needed some more rigorous error checking, I'd start running tests on all the modules - but that meant rewriting a lot of the same code.[/QUOTE] Oh don't get me wrong, I see the usefulness of test-cases, especially when you're working as a group and plugging into other people's code, or using compiled libraries, but it seems ridiculous how they want us to test *every class* - It's an awful lot of copy-and-pasting and not a lot of actual code, and marking us down for not doing it? :argh: [QUOTE=Ortzinator;28727071]I think you misunderstand the purpose of unit testing. [url]http://en.wikipedia.org/wiki/Test-driven_development[/url][/QUOTE] Ohh. If that's what my lecturers want us to do, they should've told us more about TDD. All we've been told so far is "test EVERYTHING (we need to go DEEPER)", which isn't really a whole development technique, just a habit. But naw, that wiki page makes sense, you've made stuff clearer. Just wish my lecturers had :v:
I'm gonna be writing a client/server app to run over a network and I'm wondering what the best way for the clients to collect data from the server would be. I thought the server could just broadcast a string on a UDP port every minute or so which is formatted as JSON that the clients can parse. It seems a bit shitty but I cant be arsed to write my own protocol. Has anyone got any better ideas?
[url]http://kathack.com/[/url] Well... That was fun...
[QUOTE=TehDoomCat;28726441]my latest software-dev-course assignment: "You are working in a team of software developers on a new application to help to [b]manage the process of recording marks for modules at universities.[/b]" jesus fuck this is possibly the most unimaginative, boring assignment they could've given us ): the last one was "make an application that makes it easier to create comic strips, preferably with a drag-and-drop interface"... but this? urghh... no motivation to do this... ps anyone doing a software development related course, or working - does the mantra of "write a test class for EVERYTHING" really happen in the real world? I keep losing marks for not using a single test class whilst developing applications - I mean like this: [code]SomeJavaMathClass { public static int returnsANumber() { return aNumber; } } TestSomeJavaMathClass { public void test() { int x = SomeJavaMathClass.returnsANumber(); assert x == aNumber; } } ...[/code] Because that code can fuck off, I'm quite happy using print() or a debugger to catch bugs in my program. Writing test classes for ~~EVERYTHING~~ seems like a complete waste of time. FUCK this module. /rant[/QUOTE] It's called unit testing. Rather than write a special class for each class, just write a main function for each class, making sure every function works. You obviously don't understand the purpose of it, because things like print statements or debuggers are use to [I]debug[/I] the program not to test it. The idea behind it is that you build your program out of [I]bulletproof[/I] classes, with the ability to run tests often. Whenever you make a change to a class you run the unit tests you have, and if they fail then you go and fix that problem. It's about making sure your code is correct, and doing that efficiently. Your code may be working, but what if it isn't and you find that out when you've programmed a fuck ton of other modules and then you have to sift through and find the problem when you could have been running unit tests every time you compile to make sure your code still works. They are a huge help for you because they automate testing for you, so you don't [I]have[/I] to load and run a program and try to break it. It is a chore at times, but it is an incredibly useful chore and a sign of good programming practice.
[QUOTE=Shanethe13;28720370]Graphics are to computer science what rocketships are to astronomy; they're pretty cool, but there's a lot more to the field than that. An interpreter is one of the best things to make if you want to learn computer science: it requires parsing, lexing, recursion, data-structures, and depending on how you did it, maybe even a bit of graph theory. It might not seem like it now, but you probably learned a ton of stuff from the project, a hell of a lot more than you would have learned by making a mandelbrot generator or something of the sort, at least.[/QUOTE] Well, actually... Since it's a Brainfuck interpreter I could get away with looping over the string character by character. Oh dear lord :saddowns:
[QUOTE=Nipa;28725831]I decided to start at this again. This time, I'm going to do it properly. [img_thumb]http://f.anyhub.net/2eiK[/img_thumb][/QUOTE] [media]http://imgur.com/w47Wv.png[/media] Working on the heap stuff right now.
[QUOTE=Rohans;28731178][media]http://imgur.com/w47Wv.png[/media] Working on the heap stuff right now.[/QUOTE] How long have you been studying programming that you can make this?
Porting the pixel art scaling from a few pages back to C#: [code]public static unsafe Bitmap Scale3(Bitmap bitmap, uint trY, uint trU, uint trV, uint trA) { trA <<= 3 * 8; trY <<= 2 * 8; trU <<= 1 * 8; int Xres = bitmap.Width; int Yres = bitmap.Height; int dpL = Xres * 3; var RGBtoYUV = RgbYuv.LookupTable; var dest = new Bitmap(bitmap.Width * 3, bitmap.Height * 3); var bmpData = bitmap.LockBits(new Rectangle(Point.Empty, bitmap.Size), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb); var destData = dest.LockBits(new Rectangle(Point.Empty, dest.Size), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb); { int prevline, nextline; var w = new uint[9]; uint* sp = (uint*)bmpData.Scan0.ToPointer(); uint* dp = (uint*)destData.Scan0.ToPointer(); for (int j = 0; j < Yres; j++) { if (j > 0) prevline = -Xres; else prevline = 0; if (j < Yres - 1) nextline = Xres; else nextline = 0; for (int i = 0; i < Xres; i++) { w[1] = *(sp + prevline); w[4] = *sp; w[7] = *(sp + nextline); if (i > 0) { w[0] = *(sp + prevline - 1); w[3] = *(sp - 1); w[6] = *(sp + nextline - 1); } else { w[0] = w[1]; w[3] = w[4]; w[6] = w[7]; } if (i < Xres - 1) { w[2] = *(sp + prevline + 1); w[5] = *(sp + 1); w[8] = *(sp + nextline + 1); } else { w[2] = w[1]; w[5] = w[4]; w[8] = w[7]; } int pattern = 0; int flag = 1; uint YUV1 = RGBtoYUV[0x00ffffff & w[4]]; for (int k = 0; k < 9; k++) { if (k == 4) continue; if (w[k] != w[4]) { uint YUV2 = RGBtoYUV[0x00ffffff & w[k]]; if ((Math.Abs((YUV1 & Ymask) - (YUV2 & Ymask)) > trY) || (Math.Abs((YUV1 & Umask) - (YUV2 & Umask)) > trU) || (Math.Abs((YUV1 & Vmask) - (YUV2 & Vmask)) > trV) || (Math.Abs((w[4] & Amask) - (w[k] & Amask)) > trA)) pattern |= flag; } flag <<= 1; } switch (pattern) { case 0: case 1: case 4: case 32: case 128: case 5: case 132: case 160: case 33: case 129: case 36: case 133: case 164: case 161: case 37: case 165: { *(dp) = Interpolation.Mix2To1To1(w[4], w[3], w[1]); *(dp + 1) = Interpolation.Mix3To1(w[4], w[1]); *(dp + 2) = Interpolation.Mix2To1To1(w[4], w[1], w[5]); *(dp + dpL) = Interpolation.Mix3To1(w[4], w[3]); *(dp + dpL + 1) = w[4]; *(dp + dpL + 2) = Interpolation.Mix3To1(w[4], w[5]); *(dp + dpL + dpL) = Interpolation.Mix2To1To1(w[4], w[7], w[3]); *(dp + dpL + dpL + 1) = Interpolation.Mix3To1(w[4], w[7]); *(dp + dpL + dpL + 2) = Interpolation.Mix2To1To1(w[4], w[5], w[7]); break; } case 2: case 34: case 130: case 162: { *(dp) = Interpolation.Mix3To1(w[4], w[0]); *(dp + 1) = w[4]; *(dp + 2) = Interpolation.Mix3To1(w[4], w[2]); *(dp + dpL) = Interpolation.Mix3To1(w[4], w[3]); *(dp + dpL + 1) = w[4]; *(dp + dpL + 2) = Interpolation.Mix3To1(w[4], w[5]); *(dp + dpL + dpL) = Interpolation.Mix2To1To1(w[4], w[7], w[3]); *(dp + dpL + dpL + 1) = Interpolation.Mix3To1(w[4], w[7]); *(dp + dpL + dpL + 2) = Interpolation.Mix2To1To1(w[4], w[5], w[7]); break; } case 16: case 17: case 48: case 49: { *(dp) = Interpolation.Mix2To1To1(w[4], w[3], w[1]); *(dp + 1) = Interpolation.Mix3To1(w[4], w[1]); *(dp + 2) = Interpolation.Mix3To1(w[4], w[2]); *(dp + dpL) = Interpolation.Mix3To1(w[4], w[3]); *(dp + dpL + 1) = w[4]; *(dp + dpL + 2) = w[4]; *(dp + dpL + dpL) = Interpolation.Mix2To1To1(w[4], w[7], w[3]); *(dp + dpL + dpL + 1) = Interpolation.Mix3To1(w[4], w[7]); *(dp + dpL + dpL + 2) = Interpolation.Mix3To1(w[4], w[8]); break; } case 64: case 65: case 68: case 69: { *(dp) = Interpolation.Mix2To1To1(w[4], w[3], w[1]); *(dp + 1) = Interpolation.Mix3To1(w[4], w[1]); *(dp + 2) = Interpolation.Mix2To1To1(w[4], w[1], w[5]); *(dp + dpL) = Interpolation.Mix3To1(w[4], w[3]); *(dp + dpL + 1) = w[4]; *(dp + dpL + 2) = Interpolation.Mix3To1(w[4], w[5]); *(dp + dpL + dpL) = Interpolation.Mix3To1(w[4], w[6]); *(dp + dpL + dpL + 1) = w[4]; *(dp + dpL + dpL + 2) = Interpolation.Mix3To1(w[4], w[8]); break; } case 8: case 12: case 136: case 140: { *(dp) = Interpolation.Mix3To1(w[4], w[0]); *(dp + 1) = Interpolation.Mix3To1(w[4], w[1]); *(dp + 2) = Interpolation.Mix2To1To1(w[4], w[1], w[5]); *(dp + dpL) = w[4]; *(dp + dpL + 1) = w[4]; *(dp + dpL + 2) = Interpolation.Mix3To1(w[4], w[5]); *(dp + dpL + dpL) = Interpolation.Mix3To1(w[4], w[6]); *(dp + dpL + dpL + 1) = Interpolation.Mix3To1(w[4], w[7]); *(dp + dpL + dpL + 2) = Interpolation.Mix2To1To1(w[4], w[5], w[7]); break; } case 3: case 35: case 131: case 163: { *(dp) = Interpolation.Mix3To1(w[4], w[3]); *(dp + 1) = w[4]; *(dp + 2) = Interpolation.Mix3To1(w[4], w[2]); *(dp + dpL) = Interpolation.Mix3To1(w[4], w[3]); *(dp + dpL + 1) = w[4]; *(dp + dpL + 2) = Interpolation.Mix3To1(w[4], w[5]); *(dp + dpL + dpL) = Interpolation.Mix2To1To1(w[4], w[7], w[3]); *(dp + dpL + dpL + 1) = Interpolation.Mix3To1(w[4], w[7]); *(dp + dpL + dpL + 2) = Interpolation.Mix2To1To1(w[4], w[5], w[7]); break; } case 6: case 38: case 134: case 166: { *(dp) = Interpolation.Mix3To1(w[4], w[0]); *(dp + 1) = w[4]; *(dp + 2) = Interpolation.Mix3To1(w[4], w[5]); *(dp + dpL) = Interpolation.Mix3To1(w[4], w[3]); *(dp + dpL + 1) = w[4]; *(dp + dpL + 2) = Interpolation.Mix3To1(w[4], w[5]); *(dp + dpL + dpL) = Interpolation.Mix2To1To1(w[4], w[7], w[3]); *(dp + dpL + dpL + 1) = Interpolation.Mix3To1(w[4], w[7]); *(dp + dpL + dpL + 2) = Interpolation.Mix2To1To1(w[4], w[5], w[7]); break; } [...][/code] Apart from being more readable, it has now options for AYUV tolerances and supports alpha blending. [img]http://dl.dropbox.com/u/5013896/forum/Facepunch/Programming%20WAYWO/science.gif.hi-res.png[/img]
I keep getting hit with Programmer's Apathy. I'll be tapping away at my keyboard and then suddenly just feel like there's no point to what I'm writing, and just stop.
[QUOTE=Dr Magnusson;28732524]I keep getting hit with Programmer's Apathy. I'll be tapping away at my keyboard and then suddenly just feel like there's no point to what I'm writing, and just stop.[/QUOTE] Ohhh, so that's what that's called.
[QUOTE=Tamschi;28732317]Porting the pixel art scaling from a few pages back to C#:[/QUOTE] Awesome :D Any documentation on how to use it?
[QUOTE=CarlBooth;28732546]Ohhh, so that's what that's called.[/QUOTE] Oh yeah, apparently it is. I didn't know it was a thing :v:
[QUOTE=Dr Magnusson;28732524]I keep getting hit with Programmer's Apathy. I'll be tapping away at my keyboard and then suddenly just feel like there's no point to what I'm writing, and just stop.[/QUOTE] I get that except I don't even start. I find it hard to work on games within my reach because I know that I would much rather play fallout / assassins creed or whatever. It's just like, as an individual with no skill with art production and no budget, I have no chance of producing a game anywhere near what I would enjoy playing. I'm constantly trying to think up concepts which require low media production, but unfortunately they all seem to be lacking on the fun to play side. Minecraft is a perfect example of the ultimate programmers project.
[QUOTE=ZenX2;28722248]I've been doing work on my scripting language again and was wondering; how do you implement functions? I really don't know how it is supposed to work, and wikipedia/google have failed me.[/QUOTE] What i did was have my program parse through the file at the beginning, and make a list of all the functions and entry points for those functions, and then creates a class which has an amount of memory for each function's variables and generic information When a function call is spotted in the code, copy any arguments into the functions 'class' (which it should generally access variables from), then move the programs execution to the beginning of the function (which you know from previously parsing). I have no idea if thats an orthodox thing or not, is just an outline of something i made up for me :v: Oh and i also keep a list of the function the function was called from, and the one that was called from etc etc, so i can go back when the current function finishes [editline]21st March 2011[/editline] [QUOTE=Jallen;28732934]I get that except I don't even start. I find it hard to work on games within my reach because I know that I would much rather play fallout / assassins creed or whatever. It's just like, as an individual with no skill with art production and no budget, I have no chance of producing a game anywhere near what I would enjoy playing. I'm constantly trying to think up concepts which require low media production, but unfortunately they all seem to be lacking on the fun to play side. Minecraft is a perfect example of the ultimate programmers project.[/QUOTE] This is exactly why i was messing around with procedural algorithms for generating stuff like textures.. Only have to do it once then its just messing with parameters :v:
[QUOTE=Richy19;28732606]Awesome :D Any documentation on how to use it?[/QUOTE] Give it a bitmap and the tolerances and you get a larger bitmap, for now. I'll upload it to google code after adding some documentation and the two other scalings. [editline]21th March 2011[/editline] This actually works really well with some of the smileys: [img]http://dl.dropbox.com/u/5013896/forum/Facepunch/Programming%20WAYWO/wcc.gif.hi-res.png[/img] [img]http://dl.dropbox.com/u/5013896/forum/Facepunch/Programming%20WAYWO/wookie.gif.hi-res.png[/img] [img]http://dl.dropbox.com/u/5013896/forum/Facepunch/Programming%20WAYWO/kakashi.gif.hi-res.png[/img]
[QUOTE=Jallen;28732934]I get that except I don't even start. I find it hard to work on games within my reach because I know that I would much rather play fallout / assassins creed or whatever. It's just like, as an individual with no skill with art production and no budget, I have no chance of producing a game anywhere near what I would enjoy playing. I'm constantly trying to think up concepts which require low media production, but unfortunately they all seem to be lacking on the fun to play side. Minecraft is a perfect example of the ultimate programmers project.[/QUOTE] I know what you mean. I actually went looking for spritepacks the other day to try and find a pack so big I could create a game around whatever the sprites were. How sad is that? Creating a game to fit the content!
Sorry, you need to Log In to post a reply to this thread.