• What are you working on? v15
    5,001 replies, posted
[QUOTE=SamPerson123;27909194]Now my maze generator can make mazes as big as an int. I ended up moving the switch statement outside of the other switch because I realized I needed to compare it to something else. It's a bit nicer now, but I'm sure there's a cleaner way to do it. [code] public void depthFirstGen(int X, int Y){ ArrayList<Integer> options; int rand; boolean finished = false; while(!finished){ options = new ArrayList<Integer>(); maze[X][Y][0] = true; if(X>0 && !maze[X-1][Y][0]){options.add(1);} if(X<xSize-1 && !maze[X+1][Y][0]){options.add(2);} if(Y>0 && !maze[X][Y-1][0]){options.add(3);} if(Y<ySize-1 && !maze[X][Y+1][0]){options.add(4);} if(options.size()>0){ rand = (int)(Math.random()*options.size()); switch(options.get(rand)){ case 1: maze[X][Y][1] = true; X--; dir[X][Y] = 2; break; case 2: maze[X+1][Y][1] = true; X++; dir[X][Y] = 1; break; case 3: maze[X][Y][2] = true; Y--; dir[X][Y] = 4; break; case 4: maze[X][Y+1][2] = true; Y++; dir[X][Y] = 3; break; } }else{ switch(dir[X][Y]){ case 1: X--; break; case 2: X++; break; case 3: Y--; break; case 4: Y++; break; default: finished = true; break; } } } } [/code] [editline]6th February 2011[/editline] This can do a 500x500 cell maze in half a second. [editline]7th February 2011[/editline] Got it down to .25 seconds by using the clear function instead of making a new ArrayList each time.[/QUOTE] Oyah? [code] public void depthFirstGen(long X, long Y){ ArrayList<Long> options; long rand; boolean finished = false; while(!finished){ options = new ArrayList<Long>(); maze[X][Y][0] = true; if(X>0 && !maze[X-1][Y][0]){options.add(1);} if(X<xSize-1 && !maze[X+1][Y][0]){options.add(2);} if(Y>0 && !maze[X][Y-1][0]){options.add(3);} if(Y<ySize-1 && !maze[X][Y+1][0]){options.add(4);} if(options.size()>0){ rand = (int)(Math.random()*options.size()); switch(options.get(rand)){ case 1: maze[X][Y][1] = true; X--; dir[X][Y] = 2; break; case 2: maze[X+1][Y][1] = true; X++; dir[X][Y] = 1; break; case 3: maze[X][Y][2] = true; Y--; dir[X][Y] = 4; break; case 4: maze[X][Y+1][2] = true; Y++; dir[X][Y] = 3; break; } }else{ switch(dir[X][Y]){ case 1: X--; break; case 2: X++; break; case 3: Y--; break; case 4: Y++; break; default: finished = true; break; } } } } [/code] My modified version of yours probably fails and doesn't support longs or ints! Nyehh!
[QUOTE=Map in a box;27910372]Oyah? [code] public void depthFirstGen(long X, long Y){ ArrayList<Long> options; long rand; boolean finished = false; while(!finished){ options = new ArrayList<Long>(); maze[X][Y][0] = true; if(X>0 && !maze[X-1][Y][0]){options.add(1);} if(X<xSize-1 && !maze[X+1][Y][0]){options.add(2);} if(Y>0 && !maze[X][Y-1][0]){options.add(3);} if(Y<ySize-1 && !maze[X][Y+1][0]){options.add(4);} if(options.size()>0){ rand = (int)(Math.random()*options.size()); switch(options.get(rand)){ case 1: maze[X][Y][1] = true; X--; dir[X][Y] = 2; break; case 2: maze[X+1][Y][1] = true; X++; dir[X][Y] = 1; break; case 3: maze[X][Y][2] = true; Y--; dir[X][Y] = 4; break; case 4: maze[X][Y+1][2] = true; Y++; dir[X][Y] = 3; break; } }else{ switch(dir[X][Y]){ case 1: X--; break; case 2: X++; break; case 3: Y--; break; case 4: Y++; break; default: finished = true; break; } } } } [/code] My modified version of yours probably fails and doesn't support longs or ints! Nyehh![/QUOTE] The size limit is due to the fact that arrays can't hold a larger amount of things than the size of an int.
Chandler challenged me to implement strlen, so I did: [url]http://codepad.org/bkXSK294[/url] [cpp] size_t my_strlen(char* str) { size_t len = 0; while(*str++) len++; return len; } int main() { printf("%d\n", my_strlen("Hello, World!")); } [/cpp] Then he said that he could write a better one, so he did: [url]http://codepad.org/y3cIEWz3[/url] [cpp] size_t better_strlen(const char* str) { size_t idx = 0; while (str[idx]) { ++idx; } return idx; } int main(void) { printf("%d\n", better_strlen("Hello, World!")); return 0; } [/cpp] Then I one-upped him: [url]http://codepad.org/0K9Zf8v0[/url] [cpp] size_t bestest_strlen(const char* str) { asm("xorl %%eax, %%eax\n" "movl %%ebx, %%edi\n" "repne scasb\n" "subl %%ebx, %%edi\n" "decl %%edi\n" "movl %%edi, %%eax\n" : : "b"(str)); } int main(void) { printf("%d\n", bestest_strlen("Hello, World!")); return 0; } [/cpp]
Just finished the A* base. Now to make the path reconstruction (which will be about 5 min. coding). I had a problem where I kept running into a segfault. The reason: while(nodeMap[open[sp2]].fCost<nodeMap[open[sp1]].fCost && sp1>0) Had to be switched to: while(sp1>0 && nodeMap[open[sp2]].fCost<nodeMap[open[sp1]].fCost) or it was checking the fCost to a non-existing node before it checked if it was within the boundaries.
"You can also declare an array of arrays (also known as a multidimensional array)" :aaaaa:
[QUOTE=RagingHadron;27910660]"You can also declare an array of arrays (also known as a multidimensional array)" :aaaaa:[/QUOTE] Great for tile-based games. [code] Tiles[X][Y].doStuff(); [/code]
[QUOTE=RagingHadron;27910660]"You can also declare an array of arrays (also known as a multidimensional array)" :aaaaa:[/QUOTE] I actually used an array of arrays of arrays for my maze thing.
[QUOTE=SamPerson123;27910715]I actually used an array of arrays of arrays for my maze thing.[/QUOTE] Keyvalue parsers essentially have arrays of arrays of arrays of arrays of arrays. [editline]7th February 2011[/editline] etc.
[QUOTE=geel9;27910747]Keyvalue parsers essentially have arrays of arrays of arrays of arrays of arrays.[/QUOTE] Insert Inception "layers" joke :downs:
[QUOTE=geel9;27910747]Keyvalue parsers essentially have arrays of arrays of arrays of arrays of arrays. [editline]7th February 2011[/editline] etc.[/QUOTE] no they use a dict :derp:
[QUOTE=NorthernGate;27909893]Whatever's most convenient for you and your team, though any sort of code would be helpful to someone like me. I like the idea of that vagueness the further down your timeline is, I might adapt something like that if I can get into the groove of one of those task lists.[/QUOTE] The vagueness thing just sort of happened, I recently noticed I was doing that. With my school having specific dates throughout the year that they allocate specifically for independent projects, it really helps in holding to a strict schedule. And not thinking about specific implementation of something that's a few months down the pipeline helps me stay focused.
After getting a good chunk of work out of the way, I like to unwind with an episode of spongebob. Keeps me fresh.
In my A*, I use a single array and manually parse it with (x+(width*y)). I can't remember the reason I did that, but it is a good one. Also, you remember that really large maze? I'm putting my program through a lot of stress and solving it. It sometimes slows down because a) I have it output the entire open set (debugging reasons) b) There's a battle between firefox and my program for CPU cycles c) My comp is from around 2004 (so it's slower than most) I did make it more memory efficient though. I removed the entire closed set in favor for a "state flag" in the nodes themselves as well as actually deallocating the memory from the image. It doesn't go past 6k memory while the A* is running. It does go to about 150k while extracting the image's data though... [editline]7th February 2011[/editline] Actually, disregard the 6k bit. I attempted it without other programs running and it turns out firefox was throttling it.
I decided to give the whole Cocoa development thing a go, so I fired up Xcode and got to work. [img]http://cl.ly/2h2J2m3P1g1T0x1r251d/content[/img] [img]http://cl.ly/2J1t1R1N3V1Z410T2p3I/content[/img] [img]http://cl.ly/1N3c1S2m3B1i3m3a2s1c/content[/img] [img]http://cl.ly/07251s0Q1R282d2A2C1R/content[/img] I give up. I'm obviously not up to Apple's standards.
[QUOTE=pro ruby dev;27910491]Chandler challenged me to implement strlen, so I did: [url]http://codepad.org/bkXSK294[/url] [cpp] size_t my_strlen(char* str) { size_t len = 0; while(*str++) len++; return len; } int main() { printf("%d\n", my_strlen("Hello, World!")); } [/cpp] Then he said that he could write a better one, so he did: [url]http://codepad.org/y3cIEWz3[/url] [cpp] size_t better_strlen(const char* str) { size_t idx = 0; while (str[idx]) { ++idx; } return idx; } int main(void) { printf("%d\n", better_strlen("Hello, World!")); return 0; } [/cpp] Then I one-upped him: [url]http://codepad.org/0K9Zf8v0[/url] [cpp] size_t bestest_strlen(const char* str) { asm("xorl %%eax, %%eax\n" "movl %%ebx, %%edi\n" "repne scasb\n" "subl %%ebx, %%edi\n" "decl %%edi\n" "movl %%edi, %%eax\n" : : "b"(str)); } int main(void) { printf("%d\n", bestest_strlen("Hello, World!")); return 0; } [/cpp][/QUOTE] :argh: For the record you had said I could not use assembly! Then you went and did it anyways!
[QUOTE=pro ruby dev;27912023]I decided to give the whole Cocoa development thing a go, so I fired up Xcode and got to work. [img_thumb]http://cl.ly/2h2J2m3P1g1T0x1r251d/content[/img_thumb] [img_thumb]http://cl.ly/2J1t1R1N3V1Z410T2p3I/content[/img_thumb] [img_thumb]http://cl.ly/1N3c1S2m3B1i3m3a2s1c/content[/img_thumb] [img_thumb]http://cl.ly/07251s0Q1R282d2A2C1R/content[/img_thumb] I give up. I'm obviously not up to Apple's standards.[/QUOTE] Which XCode? I had some issues with 4DP3-5 that involved text formatting but were invisible after I continued. If you think it's a real issue report it to the Radar. [editline]7th February 2011[/editline] I miss the seperate Interface Builder, though. And open nibs.
[QUOTE=pro ruby dev;27910491]Chandler challenged me to implement strlen, so I did: [url]http://codepad.org/bkXSK294[/url] [cpp] size_t my_strlen(char* str) { size_t len = 0; while(*str++) len++; return len; } int main() { printf("%d\n", my_strlen("Hello, World!")); } [/cpp] Then he said that he could write a better one, so he did: [url]http://codepad.org/y3cIEWz3[/url] [cpp] size_t better_strlen(const char* str) { size_t idx = 0; while (str[idx]) { ++idx; } return idx; } int main(void) { printf("%d\n", better_strlen("Hello, World!")); return 0; } [/cpp] Then I one-upped him: [url]http://codepad.org/0K9Zf8v0[/url] [cpp] size_t bestest_strlen(const char* str) { asm("xorl %%eax, %%eax\n" "movl %%ebx, %%edi\n" "repne scasb\n" "subl %%ebx, %%edi\n" "decl %%edi\n" "movl %%edi, %%eax\n" : : "b"(str)); } int main(void) { printf("%d\n", bestest_strlen("Hello, World!")); return 0; } [/cpp][/QUOTE] Hey, Out of curiosity, by what measure is the ASM version better than the other two? Did you compare it to the compiler's output?
The ASM version would probably only be negligibly better than the other two, and definitely worse than GCC's implementation. It was all just a pissing contest really :wink:
I'm working on implementing lua into my game engine and I came across toLua++. I love it. Iloveitiloveitiloveit
[img]http://i.imgur.com/EoESV.png[/img] Hot physics orgy :v:
[QUOTE=Dlaor-guy;27914663][img_thumb]http://i.imgur.com/EoESV.png[/img_thumb] Hot physics orgy :v:[/QUOTE] I spy Lua. TELL ME YOUR SECRETS
[QUOTE=iNova;27914679]I spy Lua. TELL ME YOUR SECRETS[/QUOTE] [url]http://love2d.org/[/url]
[QUOTE=Dlaor-guy;27914663][img_thumb]http://i.imgur.com/EoESV.png[/img_thumb] Hot physics orgy :v:[/QUOTE] Jealousy lurks from the corner.
[QUOTE=Dlaor-guy;27914663][img_thumb]http://i.imgur.com/EoESV.png[/img_thumb] Hot physics orgy :v:[/QUOTE] [img]http://gyazo.com/abd59a6ac72d2e33ed7d7c489723ec72.png[/img]
[IMG]http://i.imgur.com/59FST.png[/IMG] Working on a Flash game, where you have to jump up on blocks to escape a rising wall of lava. As you can see, I'm not much of an artist.
[QUOTE=Matoking;27915098][img_thumb]http://i.imgur.com/59FST.png[/img_thumb] Working on a Flash game, where you have to jump up on blocks to escape a rising wall of lava. As you can see, I'm not much of an artist.[/QUOTE] You could do a lot worse than that in terms of art :P Looks a tad busy to me, though I'm not sure how you could cut down on that
[QUOTE=Chris220;27915163]You could do a lot worse than that in terms of art :P Looks a tad busy to me, though I'm not sure how you could cut down on that[/QUOTE] It's going to have three difficulty levels which determine how often blocks drop and how fast lava rises.
[QUOTE=Chris220;27915163]You could do a lot worse than that in terms of art :P Looks a tad busy to me, though I'm not sure how you could cut down on that[/QUOTE] Probably just an art-style issue. We could simplify it down to tasteful gradients w/o outlines (especially at the level of abstraction we're already operating), but I really shouldn't be trusted on art issues either.
Yeah, I was gonna say it was the art style. Maybe cut down on the amount of dark bits in amongst the lights. If you keep all the art light colours, it might look a bit cleaner.
[img]http://img196.imageshack.us/img196/4377/notsureiftrolling.png[/img] On my video I posted a while back. Usually this would clearly be a joke, but this is the Youtube community we're talking about.
Sorry, you need to Log In to post a reply to this thread.