• What Are You Working On? April 2015
    1,741 replies, posted
[QUOTE=Berkin;47552351]Neat. Does it handle multi-character tokens?[/QUOTE] Yeah. It just loads into a string until it encounters a different type, if that's what you meant.
I have committed my game's lua and shader scripts to the repo incase you're interested in that dumb garbage. [url]https://github.com/RickDork/2149[/url]
Sora and 2149 look great dude!
[QUOTE=Sam Za Nemesis;47552552]Shitbuntu Phone[/QUOTE] ????? [editline]18th April 2015[/editline] Why are you calling it shit?
Talking about LÖVE and Grid's callbacks. [url]http://www.twitch.tv/andrewmcwatters[/url]
[QUOTE=Rocket;47551421][...] Now, I'm no mathematician or sound engineer, but couldn't you use something like [url=http://www.wolframalpha.com/input/?i=floor%28sin%28x%29%29+%2B+1]this[/url]?[/QUOTE] That's a really slow way of writing [URL="https://www.wolframalpha.com/input/?i=%28floor+x+*+2+mod+2%29+*+-2+%2B+1"][I](floor x * 2 mod 2) * -2 + 1[/I][/URL]. (It's not quite the same because I corrected it into centred output with a period of 1.) For generating a pure sine tone, I think it may be much faster to use an oscillator with complex numbers instead of the sine function. This will drift due to floating point error though, and while you can renormalise the amplitude, I'm not sure about about the phase. (If you use a unit amplitude, you can use [I](x - 1) / 2 + 1[/I] to approximate [I]sqrt(x)[/I] as the normalisation divisor.) [editline]edit[/editline] The fastest possible implementation (if [I]floor[/I] isn't extremely fast) would probably be if you lifted the sign bit and the bit denoting 1/2 from the float (should be possible by adding the exponent to a shift-offset) and [I]or[/I]ed their [I]xor[/I] result them into the sign bit of a 1 of any type. (You can do without the input sign if you only examine either positive or negative inputs. In the latter case [I]xor[/I] it into -1, in the former [I]or[/I] it into 1.) Of course this would assume that the input is normalised.
[QUOTE=andrewmcwatters;47552534]Sora and 2149 look great dude![/QUOTE] thank you
[QUOTE=Rocket;47551421]Nobody here is working on AAA game, so we're firmly in the realm of "can you as an indie developer make a better DRM than the AAA studios?" I would still argue that even something like just putting the game on Steam is enough to deter most pirates. I buy games on Steam because I like the convenience Steam offers. I get updates right away, I can play multiplayer without any hassle, I can post screenshots, it saves my games. I have over thirty games on my Steam wishlist right now, and I could probably pirate all of them right now, but I don't because I want them on Steam. Plus, GTA V was cracked before it was released. Those guys are FAST. [editline]18th April 2015[/editline] Now, I'm no mathematician or sound engineer, but couldn't you use something like [url=http://www.wolframalpha.com/input/?i=floor%28sin%28x%29%29+%2B+1]this[/url]?[/QUOTE] yes, or [code] foo(double x){ return sin(x) >= 0 : 1 ? -1; } [/code] But it's still fun to play around with math [editline]18th April 2015[/editline] [QUOTE=cartman300;47552561]????? [editline]18th April 2015[/editline] Why are you calling it shit?[/QUOTE] Probably a Fedora or Arch user [editline]18th April 2015[/editline] Or, even worse, a Gentoo user
[QUOTE=Darwin226;47550274]Too bad it kills removal performance, but I guess that's a relatively rare use of a dictionary.[/QUOTE] It can be partially fixed by storing [I]KeyValuePair<int, TValue>[/I]s as values in the dictionary to attach the index. If you wanted to fully fix it you could use a [I]LinkedList<TKey>[/I] and [I]KeyValuePair<LinkedListNode<TKey>, TValue>[/I]s, but of course that trades it for more memory and garbage. I don't need either since I'm strictly adding to the end of the dictionary. For highest performance in my scenario I'd use a [I]List<KeyValuePair<string, string>>[/I] instead of the whole custom dictionary, but I also want to check if keys already exist. Moving the values into the list wouldn't save memory if I still want quick guaranteed unique adding, so the [I]List<TKey>[/I] - [I]Dictionary<TKey, TValue>[/I] version is still the best scaling implementation with its nice lookups. [I]However[/I], since I'm almost always dealing with less than ten items not using a hash table could well be faster for my use case. Just using a [I]List<KeyValuePair<TKey, TItem>>[/I] likely wouldn't work though since I'm pretty sure [I]Dictionary<,>[/I] contains a lot of low-level optimisations.
I just got back from a hackathon. I didn't submit anything and I left early since I didn't know what the hell was going on (also like, 10 people showed up). Not knowing javascript is really making me feel behind other people in the field, but I'm not interested in JS
[QUOTE=proboardslol;47552999]I just got back from a hackathon. I didn't submit anything and I left early since I didn't know what the hell was going on (also like, 10 people showed up). Not knowing javascript is really making me feel behind other people in the field, but I'm not interested in JS[/QUOTE] What languages and technologies do you have experience with?
[QUOTE=Darwin226;47553040]What languages and technologies do you have experience with?[/QUOTE] C and the linux API and a few libraries. No network stuff
[QUOTE=proboardslol;47553081]C and the linux API and a few libraries. No network stuff[/QUOTE] It just seems that you've labeled a lot of things as "not my thing" very early in your programming career.
[QUOTE=Darwin226;47553128]It just seems that you've labeled a lot of things as "not my thing" very early in your programming career.[/QUOTE] Its not that i'm categorically saying I'll never do it, it's just that there are some things that I find more interesting than others and I study those things more than others
Learning linear algebra, goddamit shit is hard then it just "clicks" and you see the matrix.
My pipeline now supports unlit objects! Getting closer to having a skybox :D [img_thumb]https://hostr.co/file/YBisoGpb8w2U/engine_pretty.png[/img_thumb] (There's a cube with stars in the center, click it!)
ludum dare video game. frog temporary from maplestory [IMG]http://i.imgur.com/EHvVnw7.gif[/IMG]
Continuing with my lexer, here's calculating RPN expressions and variables: [IMG]https://dl.dropboxusercontent.com/u/46283290/RPNVars.png[/IMG] It took me about 20 minutes to figure out why variables weren't working. As it turned out, I wrote OPERATOR instead of VARIABLE in a check and for twenty minutes straight of looking at it, I thought it was correct.. :suicide:
[QUOTE=adnzzzzZ;47553709]ludum dare video game. frog temporary from maplestory [IMG]http://i.imgur.com/EHvVnw7.gif[/IMG][/QUOTE] This frog will forever stay in my head, it is just so fucking cute.
Did some quick work on Pushjet for Android Lollipop. Users that run android 5 will now see the materi I also changed the notification icon. Currently designing the desktop application and redesigning the API documentation. [t]http://i.imgur.com/V4ibYaX.png[/t]
I changed RIDE's output display to show in the same window as the editor, with a button in the top-right corner to switch between pattern/output views. You can also press Escape on the Output view to go back to editing. [vid]http://a.pomf.se/tgjnyi.mp4[/vid] [b]Edit:[/b] Here's some automatic error checking: [vid]http://a.pomf.se/yvwfmf.mp4[/vid]
Just a general question. Had someone ask me about it recently and was wondering how everyone else would do it. So the question is: Say you have an array/list of a bunch of numbers. You have to check if any 2 numbers in that array add up to a designated number. Now the method that I came up with quickly is just loop through the array like so. [code] private static void Main(string[] args) { foreach (var equal in Equals(10, 5, 5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)) { } Console.ReadLine(); } public static IEnumerable<bool> Equals(int designated, params int[] numbers) { for (int x = 0; x < numbers.Length; x++) { for (int y = 0; y < numbers.Length; y++) { Console.WriteLine("{0} + {1} = {2}", numbers[x], numbers[y], numbers[x] + numbers[y]); if (x != y) { if (numbers[x] + numbers[y] == designated) { Console.WriteLine("FOUND RESULT: {0} + {1} = {2}", numbers[x], numbers[y], designated); yield return true; } } } } yield return false; } [/code] Just some quick code. Would this be considered a good? It would probably get quite slow depending on the size of how many numbers were passed in. Thoughts?
If I was not so dead from work, losing sleep due to brother yelling as he plays GTA V, and school exam's happening in a few days, I would of loved to do something in the ludum dare happening right now.
[QUOTE=TH3_L33T;47555392]Just a general question. Had someone ask me about it recently and was wondering how everyone else would do it. So the question is: Say you have an array/list of a bunch of numbers. You have to check if any 2 numbers in that array add up to a designated number. Now the method that I came up with quickly is just loop through the array like so. [code] private static void Main(string[] args) { foreach (var equal in Equals(10, 5, 5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)) { } Console.ReadLine(); } public static IEnumerable<bool> Equals(int designated, params int[] numbers) { for (int x = 0; x < numbers.Length; x++) { for (int y = 0; y < numbers.Length; y++) { Console.WriteLine("{0} + {1} = {2}", numbers[x], numbers[y], numbers[x] + numbers[y]); if (x != y) { if (numbers[x] + numbers[y] == designated) { Console.WriteLine("FOUND RESULT: {0} + {1} = {2}", numbers[x], numbers[y], designated); yield return true; } } } } yield return false; } [/code] Just some quick code. Would this be considered a good? It would probably get quite slow depending on the size of how many numbers were passed in. Thoughts?[/QUOTE] This is just a small optimization, but you could save operations in some cases by using a HashSet instead of an array to prevent duplicate numbers from being passed in.
[QUOTE=TH3_L33T;47555392]Just a general question. Had someone ask me about it recently and was wondering how everyone else would do it. So the question is: Say you have an array/list of a bunch of numbers. You have to check if any 2 numbers in that array add up to a designated number. Now the method that I came up with quickly is just loop through the array like so. (code) Just some quick code. Would this be considered a good? It would probably get quite slow depending on the size of how many numbers were passed in. Thoughts?[/QUOTE] One immediate thing I noticed is that it would be better if the second loop started where the first currently is - no need to search numbers before, because they were already searched when first loop was over them. Eg. [code]for(int x = 0; x < numbers.Length; x++) { for(int y = x + 1; y < numbers.Length; y++) { //then you also don't need to check if x == y } }[/code] But I have a feeling that there are even better ways to solve this problem.
This might be the best bug ever, gonna keep it [vid]http://files.facepunch.com/layla/2015/April/19/2015-04-19_07-18-45.mp4[/vid] HELP [vid]http://files.facepunch.com/layla/2015/April/19/2015-04-19_07-32-54.mp4[/vid]
[QUOTE=TH3_L33T;47555392]Just a general question. Had someone ask me about it recently and was wondering how everyone else would do it. So the question is: Say you have an array/list of a bunch of numbers. You have to check if any 2 numbers in that array add up to a designated number. Now the method that I came up with quickly is just loop through the array like so. [code] private static void Main(string[] args) { foreach (var equal in Equals(10, 5, 5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)) { } Console.ReadLine(); } public static IEnumerable<bool> Equals(int designated, params int[] numbers) { for (int x = 0; x < numbers.Length; x++) { for (int y = 0; y < numbers.Length; y++) { Console.WriteLine("{0} + {1} = {2}", numbers[x], numbers[y], numbers[x] + numbers[y]); if (x != y) { if (numbers[x] + numbers[y] == designated) { Console.WriteLine("FOUND RESULT: {0} + {1} = {2}", numbers[x], numbers[y], designated); yield return true; } } } } yield return false; } [/code] Just some quick code. Would this be considered a good? It would probably get quite slow depending on the size of how many numbers were passed in. Thoughts?[/QUOTE] I have a feeling there's a better solution, but you can at least get it down to O(nlogn). The sum you're looking for is `s`. Sort the array in ascending order, then go through it. For each number `i`, if `s - i > i`, then you need to find `s - i` in the rest of the array to the right. Since it's sorted you can do that with a binary search in O(logn) time. Else, the number you want is to the left, but you can stop there because you've already gone through all the combinations.
[I]You have the tools to tread lightly.[/I] [thumb]http://i.imgur.com/6tR19j9.gif[/thumb]
[QUOTE=Darwin226;47555679]I have a feeling there's a better solution, but you can at least get it down to O(nlogn). The sum you're looking for is `s`. Sort the array in ascending order, then go through it. For each number `i`, if `s - i > i`, then you need to find `s - i` in the rest of the array to the right. Since it's sorted you can do that with a binary search in O(logn) time. Else, the number you want is to the left, but you can stop there because you've already gone through all the combinations.[/QUOTE] If you can force yourself to read Haskell. Here's an implementation [code]import Data.Vector (Vector, (!)) import qualified Data.Vector as Vector import Data.List binary :: Int -> Vector Int -> Bool binary target vec | Vector.null right = False | piv == target = True | piv < target = binary target (Vector.tail right) | otherwise = binary target left where len = Vector.length vec leftLen = len `div` 2 (left, right) = Vector.splitAt leftLen vec piv = Vector.head right canSum :: Int -> [Int] -> Bool canSum target list = any canSumFor [0..Vector.length sorted - 1] where sorted = (Vector.fromList . sort) list canSumFor i | target - n > n = binary (target - n) (Vector.drop (i + 1) sorted) | otherwise = False where n = sorted ! i [/code]
[QUOTE=Darwin226;47555838]If you can force yourself to read Haskell. Here's an implementation [code]import Data.Vector (Vector, (!)) import qualified Data.Vector as Vector import Data.List binary :: Int -> Vector Int -> Bool binary target vec | Vector.null right = False | piv == target = True | piv < target = binary target (Vector.tail right) | otherwise = binary target left where len = Vector.length vec leftLen = len `div` 2 (left, right) = Vector.splitAt leftLen vec piv = Vector.head right canSum :: Int -> [Int] -> Bool canSum target list = any canSumFor [0..Vector.length sorted - 1] where sorted = (Vector.fromList . sort) list canSumFor i | target - n > n = binary (target - n) (Vector.drop (i + 1) sorted) | otherwise = False where n = sorted ! i [/code][/QUOTE] If you're using integers and they're bounded within, say, a few million or less, instead of sorting the array, create a bitfield of all the integers within the range (where a bit is set if the integer exists). Then the algorithm runs in linear time. edit: [cpp]#include <vector> #include <algorithm> // Fixing the integer overflow bugs in the implementation is left as an exercise to the reader bool can_sum(const std::vector<int> &nums, int sum) { // Special case: The vector doesn't have enough elements for a sum. if(nums.size() < 2) { return false; } auto bounds = std::minmax_element(nums.begin(), nums.end()); int b_min = *bounds.first; int b_max = *bounds.second; if(b_min == b_max) { // Special case: There is only one distinct element in the vector. return sum == b_min + b_max; } // Create the bitfield: Initialize all bits to 0, then set the bits which // correspond to integers in the vector. std::vector<bool> bits(1 + b_max - b_min, false); for(int i : nums) { bits[i - b_min] = true; } // Check all integers, see if we have any integer 'i' for which there // exists another integer 'p' so that 'i + p = sum' for(int i : nums) { int p = sum - i; if(bits[p - b_min]) { return true; } } // No such integer exists return false; }[/cpp]
Sorry, you need to Log In to post a reply to this thread.