• What are you working on? v16
    5,004 replies, posted
[QUOTE=Darwin226;28588154]Funfact, getting a value from a dictionary with an int as a key is ~3.5 times faster than with a string as a key. [editline]13th March 2011[/editline] In C#[/QUOTE] It's because GetHashCode on an int can return the int itself, whereas the same function on a string has to compute it. Strings in C# also aren't guaranteed to have the same reference even if they contain the same data: The runtime stops checking for existing strings after a few hundred distinct ones afaik. This means that string.IsEqual() has to check both for reference and equality if there are a lot of different keys.
[QUOTE=Darwin226;28588154]Funfact, getting a value from a dictionary with an int as a key is ~3.5 times faster than with a string as a key. [editline]13th March 2011[/editline] In C#[/QUOTE] Isn't a dictionary with an int as key basically the same as an array? Dictionary: [cpp]Dictionary<int, object> d = new Dictionary<int, object>(); d[5] = something; Console.WriteLine(d[5]);[/cpp] Array: [cpp]object[] d = new object[6]; d[5] = something; Console.WriteLine(d[5]);[/cpp] That would print the same, AFAIK. Only difference here is that arrays have hard-coded limits.
Dictionary<int, object> d = new Dictionary<int, object>(); d[5] = something; would throw an error because the key 5 doesn't exist.
[QUOTE=Darwin226;28588515]Dictionary<int, object> d = new Dictionary<int, object>(); d[5] = something; would throw an error because the key 5 doesn't exist.[/QUOTE] No it doesn't. I just tested it.
[QUOTE=Darwin226;28588515]Dictionary<int, object> d = new Dictionary<int, object>(); d[5] = something; would throw an error because the key 5 doesn't exist.[/QUOTE] It doesn't. The Dictionary is basically a hash-table with equality checks.
[QUOTE=Dlaor-guy;28588486]Isn't a dictionary with an int as key basically the same as an array?[/QUOTE] In any respectable language they would be diametrically different. An array would be just an indexed chunk of memory while a dictionary would be a hashmap. The first would be used when speed is needed, the second would be used when you need to map data to arbitrary values. I don't know about C#, though.
[QUOTE=Dlaor-guy;28588486]Isn't a dictionary with an int as key basically the same as an array? Dictionary: [cpp]Dictionary<int, object> d = new Dictionary<int, object>(); d[5] = something; Console.WriteLine(d[5]);[/cpp] Array: [cpp]object[] d = new object[6]; d[5] = something; Console.WriteLine(d[5]);[/cpp] That would print the same, AFAIK. Only difference here is that arrays have hard-coded limits.[/QUOTE] The output will be different if you print every element of the collections. If you'd fill them both up with objects for the indices [0..n] then they'd behave the same, though the array has the advantage that all the memory has already been allocated and will also require less memory as it doesn't have to store the keys.
[QUOTE=CarlBooth;28588315][url]http://www.myfonts.com/fonts/fontbureau/berlin-sans/[/url] [editline]0[/editline] do I win a prize?[/QUOTE] No, you're extremely late :) You do get a cookie tough :P
[img]http://dl.dropbox.com/u/671088/pics/vim.png[/img] :3:
[QUOTE=thelinx;28589160][img_thumb]http://dl.dropbox.com/u/671088/pics/vim.png[/img_thumb][/QUOTE] That file tree is fucking sweet. What plugin is it?
I just set up a blog for myself so I can post programming (or just general tech) related posts. It's at [url]http://backwardspy.tumblr.com/[/url] if you want to have a look or maybe even follow it :3: I'm still trying to make myself a theme, so don't judge :P Any help with it would be great, I'm terrible with HTML.
[QUOTE=q3k;28589201]That file tree is fucking sweet. What plugin is it?[/QUOTE] NERDTree
[QUOTE=Chris220;28589221]I just set up a blog for myself so I can post programming (or just general tech) related posts. It's at [url]http://backwardspy.tumblr.com/[/url] if you want to have a look or maybe even follow it :3: I'm still trying to make myself a theme, so don't judge :P Any help with it would be great, I'm terrible with HTML.[/QUOTE] Oh so you're backwardspy on my friends list. :v: Always forget and never bother to ask. :v:
As promised here is the phone dev thread [url]http://www.facepunch.com/threads/1069123-Facepunch-Phone-Development-Thread?p=28589773#post28589773[/url]
Got dynamic map thumbnail generation working for the level select :D [img]http://jmazouri.com/pubfiles/dynamic.jpg[/img]
That GUI is sexy as fuck.
[QUOTE=dajoh;28590506]That GUI is sexy as fuck.[/QUOTE] Too bad I didn't make it :c I'm using this library I found: [url]http://neoforce.codeplex.com/[/url]
I Love Love2D. Five minutes of coding and I've already got a screen manager and the main menu (I just need to add moving clouds). [img]http://anyhub.net/file/281C-cloud_jump_01.png[/img]
Found a really fundamental flaw in my terrain generation that wouldn't allow me generate any maps besides one of resolution "6", and the only reason anything worked up until then was dumb luck. I'm gonna rewrite it in C++ now for the increased speed boost and for some.. Future ideas I have in mind..
[media]http://www.youtube.com/watch?v=jOyke5yaJY0[/media] Watch in HD
SO! Who knows of a portable C# .NET IDE with VS2010 solution support?
[QUOTE=geel9;28592148][media]http://www.youtube.com/watch?v=jOyke5yaJY0[/media] Watch in HD[/QUOTE] I've been watching all these videos of you developing this game and the one thing I can't stop screaming in my head is WHY CAN YOU RUN AS FAST AS YOUR BULLETS? You've never thought about speeding them up?
[QUOTE=foszor;28592475]I've been watching all these videos of you developing this game and the one thing I can't stop screaming in my head is WHY CAN YOU RUN AS FAST AS YOUR BULLETS? You've never thought about speeding them up?[/QUOTE] Just never thought about it. Simple fix.
[QUOTE=Overv;28586397]Is it hard to create your own graphics for a roguelike if you've never done it before? If you need some skill, is there a good resource for sprites/graphics?[/QUOTE] Not at all, especially not for an experienced programmer like you. For tiles: [url]http://roguebasin.roguelikedevelopment.org/index.php?title=Finding_graphical_tiles[/url] I find [url=http://pousse.rapiere.free.fr/tome/]this set[/url] and [url=http://rltiles.sourceforge.net/]this set[/url] to be particularly good.
[QUOTE=Hypershadsy;28592275]SO! Who knows of a portable C# .NET IDE with VS2010 solution support?[/QUOTE] only other C# IDE I know of besides VS is SharpDevelop, you'll probably be able to run that as a portable program. Not sure if Mono has .NET 4.0 support, though.
[img]http://anyhub.net/file/284T-cloud_jump_02.png[/img] [img]http://anyhub.net/file/284U-cloud_jump_03.png[/img] I should rename it Cow Jump. [editline]13th March 2011[/editline] [url]http://monodevelop.com/[/url] [editline]13th March 2011[/editline] [url]https://github.com/mtwilliams/Cloud-Jump/[/url]
What's the best way to know if any triangle is behind another triangle(hidden) before actually drawing?
[QUOTE=likesoursugar;28592907]What's the best way to know if any triangle is behind another triangle(hidden) before actually drawing?[/QUOTE] That's pretty vague. Are you doing a raycaster? Or just some fake 3D?
I've been working on my game for the game development competition. It's coming along very nicely in my opinion. :D It's a 2D, top down RPG game. [media]http://www.youtube.com/watch?v=oMkpiYAZqvM[/media] [code] Youtube Description Nature is going to be my entry for the FacePunch Game Development Competition. It's an RPG based off of the popular Nintendo game, Animal Crossing. It's my second game in C#, obviously not my second game. I'm just new to C#, I've always used C++. This video is about a week of work, sorry for the lack of content, been slacking. D: Audio / Music is from Maple Story. Enjoy. : ) [/code]
[QUOTE=xAustechx;28593611]I've been working on my game for the game development competition. It's coming along very nicely in my opinion. :D It's a 2D, top down RPG game. [media]http://www.youtube.com/watch?v=oMkpiYAZqvM[/media] [code] Youtube Description Nature is going to be my entry for the FacePunch Game Development Competition. It's an RPG based off of the popular Nintendo game, Animal Crossing. It's my second game in C#, obviously not my second game. I'm just new to C#, I've always used C++. This video is about a week of work, sorry for the lack of content, been slacking. D: Audio / Music is from Maple Story. Enjoy. : ) [/code][/QUOTE] This looks REALLY good for a week into development.
Sorry, you need to Log In to post a reply to this thread.