#ruby - 29 July 2018
« Back 1 day Forward 1 day »
[08:28:26] wasamasa: how do I get from the nested loop to an enumerator taking a target sum and depth?
[08:29:38] wasamasa: I don't really mind hand-coding this, but I'm sure there must be a good solution
[08:33:39] wasamasa: the goal is to do optimization with constraints, the constraint being that the individual terms have a target sum
[08:33:47] elomatreb: You could probably superficially ruby-ize it by using ranges/upto instead of the loops, but that's largely a cosmetic change
[08:34:51] wasamasa: like, by writing an enumerator calling another enumerator with a helper argument
[08:39:23] ineb: wasamasa: whats the question? generate 4 dimensional vectors with maximum sum of 5?
[08:46:29] wasamasa: but what I'm really looking for is generic code to create such sequences for any parameters
[08:47:58] wasamasa: 4 and 5 are just convenient ones for a hand-coded solution, anything larger than that becomes hard to test
[15:54:49] leitz: Can I get some scathing critique on this? Building a new workstation and getting fresh git pulls on all the git repos I was tracking. https://gist.github.com/LeamHall/8bab03229ddd1c90e30889fad1762598
[17:04:42] havenwood: leafyleong: Is the `@start_dir` meant to be the directory this file is in or the working directory when it's called?
[19:02:53] siery: Hey guys! I run into a bug in my game, particularly sprites that should be drawn on different z axis are drawn on the same. For now there are only two sprites in the game, Tiles and Items. Tile class apply the method 'create_sprite' witch simply creates a new sprite object with is is later used in the draw method. The create sprite method then contain only one line:
[19:04:43] siery: The Item class derives from tiles an the only difference in create_sprite method is that last argument witch is set to `ZOrder::ITEMS`.
[19:08:02] siery: But when I invoke some Item object with `create_sprite`, it looks like it is using the method from the Tile class. Even when I tried to print something from `create_sprite` within the Tile class, nothing happens. So I assume I have some basic misunderstanding of how Ruby handles method overwriting.
[19:14:09] siery: The current state is on the dev branch, which is exactly the one I share on the link. `item.rb` and `tile.rb` are respectively to the classes
[19:36:00] siery: The obvious fix is to remove the `creat_sprite` method from Item class and define the z_order by the argument. But I really want to understand where is the problem.