• What Are You Working On? V13
    5,003 replies, posted
I'm trying to write Minecraft's infdev-mapformat. I load the chunks I want to edit, edit them and save them, but I can't see the change ingame even though my program can see them. I suspect I'm editing the wrong chunks or mixing up some other coordinates. Any ideas how I could debug that? [b]Edit:[/b] Definitely the wrong chunks, it doesn't find any chunks around the player's current position. :frown:
Well that was awesome... [code] for (int i = 1; i < i + 1; i++) { i = (i ^ 2); Console.WriteLine(i); Console.ReadKey(); } [/code] Output: 3, 6, 5, 4, 7, 10, 9, 8, 11, 14, 13, 12, 15, 18, 17, 16... etc. I CALL IT THE FACEPUNCH SEQUENCE!
i < i + 1 :eng99:
What would you suggest? i < i++ doesn't work. [editline]16th October 2010[/editline] I wanna see Nulls grapher plot it =D
[code]for(int i = 0; true; ++i) { //do stuff if(i == Int32.MaxValue) break; }[/code] Or [code]for(int i = 0; i != Int32.MinValue; unchecked(++i)) ...[/code]
Huh, never really thought about that.
Edited in another version. C# offers keywords (checked, unchecked) to define what shall happen upon arithmetic overflow.
+3 +3 -1 -1 [editline]16th October 2010[/editline] You actually get started weird because the i++ doesn't affect the first iteration. [editline]16th October 2010[/editline] Also, what's wrong with "i < i + 1"?
Can't you just do "true" instead of " i < i + 1"?
[QUOTE=RyanDv3;25440678]+3 +3 -1 -1 [editline]16th October 2010[/editline] You actually get started weird because the i++ doesn't affect the first iteration. [editline]16th October 2010[/editline] Also, what's wrong with "i < i + 1"?[/QUOTE] Because i is always smaller than itself + 1. May as well put true and skip the arithmetic and comparison.
Fixed...
[QUOTE=thomasfn;25440831]Because i is always smaller than itself + 1. May as well put true and skip the arithmetic and comparison.[/QUOTE] ^this Apart from the thing about overflowing arithmetic. And the argument against just using true is, that it may throw an exception. If it doesn't it will just wrap around and go into infinity. I think you can control this via a compiler flag - or via the use of checked and unchecked. [QUOTE=Loli;25440841]Fixed...[/QUOTE] Fixed what? Something else was broken?
[QUOTE=thomasfn;25440831]Because i is always smaller than itself [...][/QUOTE] ...but it's not. Unless C# does it differently than C++, i should overflow and then that condition will evaluate to be false and the loop will exit.
[QUOTE=ZeekyHBomb;25440846]^this Apart from the thing about overflowing arithmetic. And the argument against just using true is, that it may throw an exception. If it doesn't it will just wrap around and go into infinity. I think you can control this via a compiler flag - or via the use of checked and unchecked. Fixed what? Something else was broken?[/QUOTE] Naa... Just fixed that bit. As I probably said, this was made in about a minute so it's bound to have 1,000,000 plus errors. [/exaggeration]
wait, that would only work if it was incrementing by one each time, nevermind you guys are right
[QUOTE=RyanDv3;25440882]...but it's not. Unless C# does it differently than C++, i should overflow and then that condition will evaluate to be false and the loop will exit.[/QUOTE] C# does specify behavior when using unchecked/checked. However, using a condition like this does not really make it obvious what the purpose it or if it was intended. Further more, afaik C++ does not specify that numbers wrap around upon overflow. [QUOTE=RyanDv3;25440949]wait, that would only work if it was incrementing by one each time, nevermind you guys are right[/QUOTE] I as well totally missed the assignment part. Well then, it will still be more obvious via just using true. Plus i might become Int32.MaxValue and overflow.
[QUOTE=ZeekyHBomb;25440959]C# does specify behavior when using unchecked/checked. However, using a condition like this does not really make it obvious what the purpose it or if it was intended. Further more, afaik C++ does not specify that numbers wrap around upon overflow.[/QUOTE] It does for unsigned integers, but signed integers overflowing is undefined behavior.
[QUOTE=noctune9;25441007]It does for unsigned integers, but signed integers overflowing is undefined behavior.[/QUOTE] Signed integers are represented in two's-compliment notation, so when when you increment the highest possible positive value (0x7FFFFFFFF), you usually get the lowest possible negative value (-2147483648 or 0x80000000). It's probably not standardized behavior in C++, but I think you can pretty much rely on it because this is how almost every processor does arithmetic.
All this talk about square roots made me make my own implementation in Python using only the basic operations: [code]def squareroot(number, precision = 5): # precision is the number of decimals that the square root must be accurate to if number < 0: raise ValueError("Can't calculate square root of negative numbers.") elif number == 1: return 1 elif number == 0: return 0 elif number > 1: # sqrt is lower than number high = number else: # sqrt is higher than number high = 1 low = 0 mid = high / 2 test = mid ** 2 while round(test, precision) != round(number, precision): if test > number: high = mid else: low = mid mid = (low + high) / 2 test = mid ** 2 return mid [/code] This is the only method of doing it that i know of, and I'm sure much faster ones exist. But it's easily extensible to other root powers :v: (i think i'm gonna go do that right now)
This square root argument could easily be the basis for an XKCD cartoon.
I'd do it with Newton's method. For square root (i.e. solving x^2 = a where x is unknown) [img]http://www.codecogs.com/gif.latex?x_{n+1}%20=%20x_n%20-%20{{{x_n}^2%20-%20a}%20\over%20{2x_n}}[/img] And to extend it to any root [i]r[/i], you'd do [img]http://www.codecogs.com/gif.latex?x_{n+1}%20=%20x_n%20-%20{{{{x_n}^r}%20-%20a}%20\over%20{r%20\times%20{x_n}^{r%20-%201}}}[/img] [img]http://www.codecogs.com/gif.latex?x_0%20=%20a[/img] might be a good enough approximation to get the method started because it's such a great method [editline]16th October 2010[/editline] then again there's no problem i wouldn't try to solve with newton's method
[QUOTE=Richy19;25436793]Dont know if anyone is interested, but i just created a group for anyone that uses C++ [url]http://www.facepunch.com/group.php?groupid=1896[/url][/QUOTE] Meh, groups are useless, people just join them and then don't post in them. Kinda like Facebook fan pages.
[QUOTE=shill le 2nd;25443157]Meh, groups are useless, people just join them and then don't post in them. Kinda like Facebook fan pages.[/QUOTE] Oh well, its there if needed :P
[url]http://www.folklore.org/StoryView.py?project=Macintosh&story=Round_Rects_Are_Everywhere.txt[/url]
[QUOTE=RyanDv3;25440882]...but it's not. Unless C# does it differently than C++, i should overflow and then that condition will evaluate to be false and the loop will exit.[/QUOTE] I was actually talking in a mathematical context, where a variable has no limitations on size or decimal places. But you're right, it would overflow in a programming context. [editline]16th October 2010[/editline] Made more progress on my engine. I don't have any pictures to show this time, but now the server streams the next row of tiles when you start moving. A whole load of other small bug fixes and improvements too, like not being able to walk off one end of the terrain and "wrap" round to the other side. Also, little labels that appear above each player character so you can tell who's who. (I use gluProject, but it behaves a bit weird and doesn't like camera yaw very much). I'll see about making a video of sorts tommorow.
[QUOTE=thomasfn;25444462]I was actually talking in a mathematical context, where a variable has no limitations on size or decimal places. But you're right, it would overflow in a programming context. [editline]16th October 2010[/editline] Made more progress on my engine. I don't have any pictures to show this time, but now the server streams the next row of tiles when you start moving. A whole load of other small bug fixes and improvements too, like not being able to walk off one end of the terrain and "wrap" round to the other side. Also, little labels that appear above each player character so you can tell who's who. (I use gluProject, but it behaves a bit weird and doesn't like camera yaw very much). I'll see about making a video of sorts tommorow.[/QUOTE] Still more then me; I've been lazy. [img]http://localhostr.com/files/84522f/Fate.png[/img] Basic Quads :) I've got to re-write my networking code now :ohdear:
One of the "cool new features" in Python 2.7 is the argparse module (which is available for Python 2.6 as a separate module, so some backwards compatibility is available). One of the advantages of this, is the ability to add "subparsers" for commands (think SVN, Mercurial, or git, and their subcommands). One of make's features (as well as msbuild, and xcode) is the ability to specify which part of the project you would like to compile. bit is going to have this feature as well. Say you have two projects: Qt, and GTK. [code] with Project('Qt') as qt: # Add settings and such here with Project('GTK') as gtk: # Add Settings and such here [/code] Well we're only going to really want one of these, and the release version at that, so from the commandline we can run [code] bit qt release [/code] And the qt release target will be the only one run/compiled. Of course if we don't specify which target we want it will run through all of them. [code] bit debug [/code] And by default, bit will run through a configuration of "all debug" just by calling it on its own. Also, Te use of the "with" keyword up there is so that your project is automatically registered with the bit workspace (sort of like a Visual Studio Solution). The only reason that it does not do this automatically when creating a project is to allow for required dependencies. For instance, say we want to compile an SFML binding for Lua, we would want something like [code] with Project('SFML-Binding') as sfml: lua = Project('lua') # Perform lua settings here sfml.require(lua) [/code] Which will ensure that the Lua project is (successfully!) compiled, before we can even try to compile the sfml project. Overall, I'm thinking this version of bit is going to be much better than its predecessors. :)
Got a beta version of TextCraft that i want anyone who's interested in testing to test and report any bugs they encounter :buddy: Can be downloaded at - [url=http://filesmelt.com/dl/TextCraft.rar]Filesmelt[/url] (Forgot to edit the shortcut, so just make your own shortcut with "devmode" as a parameter, or edit the current one to fit your current directory) [release] Some things you should know that i know before reporting any bugs: - I know maximum stack property isn't working yet. - ChanceToFind isn't working yet either, it's yet to be implented properly. - You can add "RemoveOnCraft" property to your items manually, then either true or false. Will make the item dissapear(or not) when it's used in a crafting recipe. (I forgot to edit this into autocreation and devmode before uploading :sigh:) - You can type "cancel" when creating new stuff in devmode to cancel creating an item/craftable. (Just haven't made this obvious yet)[/release]
How do you Search for and craft with items.
[QUOTE=Dj-J3;25449768]-Text Craft-[/QUOTE] Neat game. I didn't come across any bugs but my suggestions are as follows: -Auto Save (didn't save my first game, feels bad man :( ) -Crafting of multiple items (like 2 wood and 1 stone to make spear) -Having a couple of default items -Displaying the items that already exist when making a new combo -When the game starts out displaying the inventory Hope to see more improvements :) Actually I found a bug, if you make a combo of the same item (1 stone and 1 stone) the game says you don't have enough of it to craft.
Sorry, you need to Log In to post a reply to this thread.