On November 22 2016 19:23 Manit0u wrote:
Amazing...
width = Math.ceil(width);
width = Math.round(width);
Amazing...
Enjoying your new job, are you? :'D
Forum Index > General Forum |
Thread Rules 1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution. 2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20) 3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible. 4. Use [code] tags to format code blocks. | ||
Acrofales
Spain17831 Posts
November 22 2016 10:24 GMT
#16001
On November 22 2016 19:23 Manit0u wrote:
Amazing... Enjoying your new job, are you? :'D | ||
icystorage
Jollibee19343 Posts
November 22 2016 11:50 GMT
#16002
| ||
Djagulingu
Germany3605 Posts
November 22 2016 11:58 GMT
#16003
On November 22 2016 19:23 Manit0u wrote:
Amazing... What's amazing here, I'm missing it. Do you need to execute them both to get the desired result or the fact that you can do Math.ceil and Math.round feels amazing to you after years and years of PHP | ||
Nesserev
Belgium2760 Posts
November 22 2016 12:02 GMT
#16004
| ||
Djagulingu
Germany3605 Posts
November 22 2016 13:27 GMT
#16005
On November 22 2016 21:02 Nesserev wrote: Show nested quote + On November 22 2016 20:58 Djagulingu wrote: On November 22 2016 19:23 Manit0u wrote:
Amazing... What's amazing here, I'm missing it. Do you need to execute them both to get the desired result or the fact that you can do Math.ceil and Math.round feels amazing to you after years and years of PHP It's amazing that someone could write such code... it's a real WTF... calling Math.round is totally unneccessary. I don't wanna believe that someone was dumb enough to write a Math.round right below a Math.ceil. | ||
Manit0u
Poland17185 Posts
November 22 2016 13:41 GMT
#16006
On November 22 2016 19:24 Acrofales wrote: Show nested quote + On November 22 2016 19:23 Manit0u wrote:
Amazing... Enjoying your new job, are you? :'D My new job starts on the 1st of December. I'm still fighting with the old shit ![]() | ||
![]()
tofucake
Hyrule18968 Posts
November 22 2016 13:48 GMT
#16007
On November 22 2016 20:58 Djagulingu wrote: Show nested quote + On November 22 2016 19:23 Manit0u wrote:
Amazing... What's amazing here, I'm missing it. Do you need to execute them both to get the desired result or the fact that you can do Math.ceil and Math.round feels amazing to you after years and years of PHP using round after ceil is pointless because ceil rounds up | ||
Mr. Wiggles
Canada5894 Posts
November 22 2016 14:53 GMT
#16008
On November 22 2016 22:27 Djagulingu wrote: Show nested quote + On November 22 2016 21:02 Nesserev wrote: On November 22 2016 20:58 Djagulingu wrote: On November 22 2016 19:23 Manit0u wrote:
Amazing... What's amazing here, I'm missing it. Do you need to execute them both to get the desired result or the fact that you can do Math.ceil and Math.round feels amazing to you after years and years of PHP It's amazing that someone could write such code... it's a real WTF... calling Math.round is totally unneccessary. I don't wanna believe that someone was dumb enough to write a Math.round right below a Math.ceil. I'm wondering what source control history would show for that. Was the second line added months later, was it put in at the same time? Maybe it used my favourite encountered commit message: "fixes an bug" | ||
Manit0u
Poland17185 Posts
November 22 2016 16:39 GMT
#16009
On November 22 2016 23:53 Mr. Wiggles wrote: Show nested quote + On November 22 2016 22:27 Djagulingu wrote: On November 22 2016 21:02 Nesserev wrote: On November 22 2016 20:58 Djagulingu wrote: On November 22 2016 19:23 Manit0u wrote:
Amazing... What's amazing here, I'm missing it. Do you need to execute them both to get the desired result or the fact that you can do Math.ceil and Math.round feels amazing to you after years and years of PHP It's amazing that someone could write such code... it's a real WTF... calling Math.round is totally unneccessary. I don't wanna believe that someone was dumb enough to write a Math.round right below a Math.ceil. I'm wondering what source control history would show for that. Was the second line added months later, was it put in at the same time? Maybe it used my favourite encountered commit message: "fixes an bug" The only available history for it is when they moved from svn to git over a year ago. I don't have access to anything prior to that. Considering how the rest of the code base looks for this system I think it's a pretty safe bet to assume that both lines were created at the same time. Another possibility is a sloppy merge, but there's no history for that. | ||
Neshapotamus
United States163 Posts
November 22 2016 19:39 GMT
#16010
On November 22 2016 17:50 Neshapotamus wrote: Don't know why your using a generic V. Use integer instead. Why? It is much more straight forward to use an integer. Generics are a template. At this point, you already know the structure. No need to complicate your code by using generics. From looking at his code, he is getting confused cause he is dealing with all different types of topics like generics, hashmaps. hashsets, linkedlist. Visited should be a boolean array. The size of visited should be equal to the number of verticies. Make this a class level scope. Why? he should do this so he can re-use this for DFS You don't have to explicitly terminate your algorithms. It will reach all the connected components by itself and complete. Still have to check whether you reached end or not. No need to keep searching the graph if you found your destination. Moreover, you want it to terminate differently, e.g. return true if it found end and false if it didn't. That is missing from the algorithm, I agree. BFS/DFS has the property that it will only visit the nodes that it is part of its network. The algorithm will auto terminate after it has visited every node. Yes, you can add an early termination, but what if you are given an end vertex that is not part of the connected components? You will traverse the entire graph anyways. It runs in O(V + E) time if you are using an adjacency list, which is pretty darn fast. DFS should be implemented using recursion. Otherwise, you will have to create your own stack. This is where having visited at a class scope will help. You bfs has a fundamental problem. *Write the for loop first *Inside the for loop, check to see if you have visited the adjacent nodes. Then mark the adjacent nodes as being visited. Some other tips: Don't use a hashmap, use an array. (You can create an array of list<int> per index. The index of the array maps to vertex.) You're making some assumptions here about the form of the input he's getting. But yes, numbering the nodes and using an array would also be a more efficient way of checking whether a node was visited than using a hashset. Yes, I am making several assumptions. Since we know this is a graph search problems, I can infer from this statement that he is given the total number of vertices and the edges between each vertex was given ahead of time (the edges are not dynamic) before calling bfs. You have to do a little bit of pre-processing to get to this state from whatever his input would be. I am trying to help him understand the basic concept with only the minimum amount code he needs to accomplish his task. Create a variable called PathTo. PathTo should be a integer array; The size of PathTo array should be equal to the number of verticies. You will need this to build a complete path from source to destination. Here is a method you should implement if you take my suggestion above: public boolean hasPathTo(int v); //run in constant time public Iterable<Integer> pathTo(int v); //use the PathTo variable and create a path You're assuming he has to return the path. Might all be unnecessary. - I am suggesting this to help him debug. | ||
Blisse
Canada3710 Posts
November 22 2016 22:56 GMT
#16011
On November 22 2016 19:23 Manit0u wrote:
Amazing... I remember seeing this in Java before. Math.ceil takes a double and returns a double Math.round takes a double and returns a long Instead of doing `int w = (int) Math.ceil(width);` you would do `int w = Math.round(Math.ceil(width));` if you wanted to get the nearest number rounded up. In this case though, who really knows why they're reassigning the long result back to the double width... | ||
Deleted User 3420
24492 Posts
November 23 2016 02:17 GMT
#16012
this was the dumbest project ever the problem is clearly the tests appreciate all the replies though Unfortunately if I had more time I would use your suggestions to clean up my code. Maybe I could simplify some of this to figure out what is going on.. or at least pass the stupid tests anyways. What's sad is that I actually broke the GUI and started passing more tests (and the changes I made make absolutely no sense at all) | ||
Manit0u
Poland17185 Posts
November 23 2016 03:35 GMT
#16013
On November 23 2016 07:56 Blisse wrote: Show nested quote + On November 22 2016 19:23 Manit0u wrote:
Amazing... I remember seeing this in Java before. Math.ceil takes a double and returns a double Math.round takes a double and returns a long Instead of doing `int w = (int) Math.ceil(width);` you would do `int w = Math.round(Math.ceil(width));` if you wanted to get the nearest number rounded up. In this case though, who really knows why they're reassigning the long result back to the double width... Want to hear the best part? It's JavaScript ![]() | ||
Hanh
146 Posts
November 23 2016 04:17 GMT
#16014
On November 23 2016 11:17 travis wrote: well w/e this was the dumbest project ever the problem is clearly the tests appreciate all the replies though Unfortunately if I had more time I would use your suggestions to clean up my code. Maybe I could simplify some of this to figure out what is going on.. or at least pass the stupid tests anyways. What's sad is that I actually broke the GUI and started passing more tests (and the changes I made make absolutely no sense at all) Regardless of the quality of the tests, Acrofales is right and you aren't implementing BFS correctly. You actually just need to move a line of your code. | ||
Deleted User 3420
24492 Posts
November 23 2016 04:22 GMT
#16015
didn't actually stop me from passing the test, though. which is kind of funny. | ||
WarSame
Canada1950 Posts
November 23 2016 04:23 GMT
#16016
The heartbeat: def run_game(self): where draw_screen is def draw_screen(self): The problem is that I can make the trolls slow down by increasing the wait time between game cycles, but then the player moves too slowly. I'm looking for a fair way to slow down how frequently the trolls move. Any ideas? | ||
meatpudding
Australia520 Posts
November 23 2016 04:49 GMT
#16017
On November 23 2016 13:23 WarSame wrote: I'm making a dungeon game and my trolls around running around like they're on meth. I can't figure out how to calm them down. This is in pygame. The heartbeat: def run_game(self): where draw_screen is def draw_screen(self): The problem is that I can make the trolls slow down by increasing the wait time between game cycles, but then the player moves too slowly. I'm looking for a fair way to slow down how frequently the trolls move. Any ideas? Lots of ways to do this. In move_creatures you could add a counter like this counter += 1 | ||
Acrofales
Spain17831 Posts
November 23 2016 07:16 GMT
#16018
On November 23 2016 13:23 WarSame wrote: I'm making a dungeon game and my trolls around running around like they're on meth. I can't figure out how to calm them down. This is in pygame. The heartbeat: def run_game(self): where draw_screen is def draw_screen(self): The problem is that I can make the trolls slow down by increasing the wait time between game cycles, but then the player moves too slowly. I'm looking for a fair way to slow down how frequently the trolls move. Any ideas? I believe the solution is: self.remove_meth() ![]() | ||
Nesserev
Belgium2760 Posts
November 23 2016 14:17 GMT
#16019
| ||
![]()
tofucake
Hyrule18968 Posts
November 23 2016 15:15 GMT
#16020
![]() some of our devs need to learn how to manage their queries :\ | ||
| ||
![]() StarCraft 2 StarCraft: Brood War Calm Dota 2![]() Rain ![]() Sea ![]() Horang2 ![]() Mini ![]() Shuttle ![]() hero ![]() Mong ![]() Rock ![]() sSak ![]() [ Show more ] HiyA ![]() Terrorterran ![]() Aegong ![]() Killer ![]() zelot ![]() soO ![]() sorry ![]() IntoTheRainbow ![]() SilentControl ![]() Movie ![]() League of Legends Counter-Strike Other Games hiko1438 ScreaM1303 Beastyqt1019 Fuzer ![]() FrodaN369 Lowko364 crisheroes320 OGKoka ![]() Liquid`VortiX150 ArmadaUGS144 QueenE113 Trikslyr54 Organizations
StarCraft 2 • StrangeGG StarCraft: Brood War![]() • LUISG ![]() • IndyKCrew ![]() • AfreecaTV YouTube • sooper7s • intothetv ![]() • Kozan • Migwel ![]() • LaughNgamezSOOP • Laughngamez YouTube Dota 2 League of Legends |
Monday Night Weeklies
PiGosaur Monday
Replay Cast
Replay Cast
SOOP
SKillous vs Spirit
Tenacious Turtle Tussle
PiG Sty Festival
The PondCast
Replay Cast
PiG Sty Festival
[ Show More ] Replay Cast
Korean StarCraft League
PiG Sty Festival
SC Evo Complete
[BSL 2025] Weekly
PiG Sty Festival
Sparkling Tuna Cup
|
|