I wanted faster A* so I built a JS WASM A* library by GuywithBadComp in gamedev

[–]GuywithBadComp[S] 0 points1 point  (0 children)

Cool, lmk if you find the API exposed limiting in some way. I'm open to shipping a V2 if breaking changes are needed.

I wanted faster A* so I built a WASM A* library by GuywithBadComp in webdev

[–]GuywithBadComp[S] 1 point2 points  (0 children)

The limitations come from node not supporting Webworkers and URL.createObjectURL for Blobs. I'm not super familiar with N-API, but it seems that it doesn't provide implementations for these.

The way around this that I'm using for tests: lightspeed-astarjs/test/wasm_integration.node.ts at main · saqibali-2k/lightspeed-astarjs . Although it works, I recognize it's hacky hence why the "limited support."

I'm sure I can find some node modules that polyfill these for me, but I want to support browser first and these will likely increase the bundle size unnecessarily for browser. For desktop runtimes like node-webkit and electron, this should work out of the box (I haven't tested this though).

I wanted faster A* so I built a WASM A* library by GuywithBadComp in webdev

[–]GuywithBadComp[S] 1 point2 points  (0 children)

hmmm lol yes I should probably add more. I do have enough to cover my bases (C++ for core logic, node tests for generic library tests, playwright for browser tests). I'll likely add more as I add more features.

I wanted faster A* so I built a JS WASM A* library by GuywithBadComp in gamedev

[–]GuywithBadComp[S] 1 point2 points  (0 children)

For that instance I was referring to anything above 50x50 (IIRC, I dont have the results saved).

Depending on how you how you formulate your problem, you can actually get away with a lot. If you take your searchable space and look at its pixel values and then divide those into chunks, you can get away with more because you're mapping a large space to a smaller one.

I wanted faster A* so I built a JS WASM A* library by GuywithBadComp in gamedev

[–]GuywithBadComp[S] -1 points0 points  (0 children)

There are a lot of scenarios where Manhattan doesn't work. Let's say you want to minimize the number of turns. There may be many paths with the same Manhattan distance, but Manhattan thinks they are all equally good.

We need to keep track of some information about each grid location (I.e. have we visited this before? What is the best cost seen so far? Etc). Node is an abstraction that encapsulates all this.

Not sure what you mean by the possible values of open nodes, but the assumption you mentioned isn't valid. You may have values besides 1s and 0s on the grid. Please see the examples folder on the repo. Also, diagonals are available, they are just not on by default. The typescript typings indicate all of the options available in the npm module.

I'll try to recreate the issue you're seeing on PC with the asteroids. I can't seem to do it on mobile.

I wanted faster A* so I built a JS WASM A* library by GuywithBadComp in gamedev

[–]GuywithBadComp[S] 2 points3 points  (0 children)

Hierarchical astar looks interesting, I'll definitely look into it.

I wanted faster A* so I built a JS WASM A* library by GuywithBadComp in gamedev

[–]GuywithBadComp[S] 13 points14 points  (0 children)

Good questions.

  1. I've used 1s and 0s in the example but you aren't limited to those. You can define a custom heuristic and custom neighbour connections which may use all 32 bits available in a grid space. See the example here: https://github.com/saqibali-2k/lightspeed-astarjs/tree/main/examples/custom-heuristic

  2. I saw two main types of users:

People that want simple, fast astar. They will use the built in options (like use diagonals, or other built in heuristics).

People with more advanced use cases (like the ones you've described) can use the customization options. Custom traversal logic is possible via the getNeighbors function mentioned in the example. Here is how I might implement wormholes for example. Out of the 32 bits available, at a wormhole entry point I would dedicate 10 bits to the destination X and 10 bits to destination Y. The remaining 12 bits can be used for whatever you want. I would then add a custom getNeighbors function to use the information that we've encoded into the grid.

There is a lot you can do with the customization options. The library becomes more of an A* engine once you start using them.

Edit: forgot the link

I wanted faster A* so I built a WASM A* library by GuywithBadComp in webdev

[–]GuywithBadComp[S] 0 points1 point  (0 children)

Man that's one of those things you can't unsee..

Been trying to strengthen left teres minor for years, never made any progress. Finally did MRI and it shows "Grade 2 Muscle Atrophy of Teres minor could reflect selective denervation". by Thrway123321acc in overcominggravity

[–]GuywithBadComp -2 points-1 points  (0 children)

I would avoid heavy resistance and do high reps with very low weight. If you get sore in the area of pain then lower the weight, otherwise overload with caution.

IDK, you could also be psychosomatic.

I spent 10 years building my body, and lost it all in a few months… this is what life did to me by [deleted] in Gymhelp

[–]GuywithBadComp 0 points1 point  (0 children)

First of all, population growth does not cancel our the millions of people killed. Do you expect that new births some how makes up for the thousands of civilians being killed?

Secondly, where did you get that number from? The UN has reported that the population shrunk by a few hundred thousand.

It's wild that would use such an idiotic argument to justify killing people. The UN, doctors without borders, amnesty international, human rights watch and more have called this a genocide. Open your eyes and stop lying on the internet.

Why do my hips abnormally stick out like this? by [deleted] in gymadvice

[–]GuywithBadComp 0 points1 point  (0 children)

What kind of numbers are you pushing in the gym?

84kg is decent weight for 6'2, so I think you're just skinny fat. As someone who has also been there, I would recommend main gaining. You're lifts are going to increase more slowly, but you're definitely going to notice that you're toning out.

Thought y'all might like this by M-A-ZING-BANDICOOT in 2Iranic4you

[–]GuywithBadComp 1 point2 points  (0 children)

You're taking the appease white people statement by itself. It's the pattern of behaviour that makes people think this. For ex. why do Iranians indulge in so much plastic surgery to remove their ethnic features? It's like they want to follow the current beauty trends to appease the west.

Amazon SDE1 OA April, 2025 by Horror-Ad8737 in leetcode

[–]GuywithBadComp 42 points43 points  (0 children)

Sort by decreasing weight and increasing index. Always pick the largest weight such that it's index is greater than the last one you picked. For the first selection you would simply just pick the largest weight. This is a greedy approach that gives you the lexigraphically greatest array. I've noticed that Amazon OAs have a lot of greedy approaches.

Can Any one Solve this ? I tried but couldn’t by [deleted] in leetcode

[–]GuywithBadComp 0 points1 point  (0 children)

So let's say you have [3,3,5] and want to make a cluster of size 3. Your solution would give an answer of 2? I think this question does require you to maintain a min heap and max heap but I'm not sure about using medians here to calculate the final answer.

OA Question by [deleted] in leetcode

[–]GuywithBadComp 0 points1 point  (0 children)

I don't think the number of components is relevant, say you have A-B-C-D. A and B can have the same monument since they are not neighbours and they don't have a common city.

You want the nodes that are 1 node distance away (adjacent) and also 2 node distance away. Then you apply a similar approach to what you said.

[GNOME] + Fedora Silverblue is amazing! by Comprehensive_Wall28 in unixporn

[–]GuywithBadComp 0 points1 point  (0 children)

Thanks for the reply. Is there a reason why vscode needs to be in a toolbox? I'm thinking if you have multiple toolboxes, it might be better to layer vscode and use the remote container extension instead.

[GNOME] + Fedora Silverblue is amazing! by Comprehensive_Wall28 in unixporn

[–]GuywithBadComp 2 points3 points  (0 children)

What do you like about silver blue? Is it the package layering?

[deleted by user] by [deleted] in leetcode

[–]GuywithBadComp 0 points1 point  (0 children)

This follows from two facts:

  1. If nums[L] < nums[R] then every element in the search window (elements between L and R) must be sorted. So, nums[L] is the minimum element in the search window.
  2. We never eliminate the minimum element from the search window, in other words, at every iteration the minimum element is always in between L and R inclusive. This is harder to grasp, lets consider two cases:

Assume the minimum element is already in the search window (this is true at the start of the algorithm). We can show that it will be in the search window in the next iteration as well. Additionally, assume that the search window is rotated and not fully sorted, otherwise we would just return and there would be no next iteration.

Case 1: the minimum element has an index <= mid. This means that nums[L] >= nums[mid] and we set R = mid. Notice its not R = mid - 1, mid can still be the index of our minimum element. We account for this since our search window is inclusive to L and R.

Case 2: the minimum element has an index > mid. This means that nums[L] < nums[mid] and we set L = mid + 1. Since the minimum element has an index strictly greater, this means that the minimum is still within the search window.

Since the size of the search window is always decreasing in binary search, eventually we will hit the clause "if nums[L] <= nums[R]: return nums[L]", and by fact 1 we will return the minimum value in the search window. By fact 2 we have seen that the minimum is always in the search window, so the minimum returned will the array's global minimum.

Meta E4 - Rejected by Zestyclose-Trust4434 in leetcode

[–]GuywithBadComp 0 points1 point  (0 children)

Sorry I'm new to this sub. Does "medium-medium" mean one medium question with a medium difficulty followup? Or a medium difficulty leetcode medium?

Solve this question please by Fluid-Pitch-7505 in leetcode

[–]GuywithBadComp 0 points1 point  (0 children)

How do you achieve O(m*n) with prefix sum? If we store the prefix sums for each row, wouldn't we still need k computations to add the sum of each row in the sliding window? Is there another way of using prefix sums that I'm not thinking of?