MatheusRich / MatheusRich/rich_engine

Helpers

Open
#10 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
1
Forks
0
Avg merge
9d 1h
Merged PRs (30d)
1

Description

  • Weighted sample
class Hash
  def wsample
    max_by { |_, w|
      next -Float::INFINITY if w == 0

      rand**(1.0 / w)
    }&.first # first to return just the key
  end

  def wsample_strict
    total_probability = values.sum
    raise ArgumentError, "Weights must add up to 1, but they add up to #{total_probability}." if total_probability != 1

    wsample
  end
end
  • bresenham's line
  • @canvas.draw_line/draw_rect_outline

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files or tests are named. Start by locating the code behind @canvas.draw_line and @canvas.draw_rect_outline and inspecting how helpers are organized; done means the weighted sampling helpers, Bresenham line, and requested canvas drawing helpers are implemented and covered by the project's existing checks.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
game-dev
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.