Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weighted Reaction System 2.0 Concept #85

antonkomarev opened this issue Jul 27, 2019 · 2 comments


Copy link

commented Jul 27, 2019

Resolves #26 #73


We need to allow people to react to the reactants with more pressure or multiple times with one type.

It was designed as #26 Reaction Power initially, but I decided to reserve word power for Reacter's authority.

Use cases

  • React multiple times on the same post with Claps on
  • Have more influence on the vote weight with Authority on
  • US Electoral System, when voting power depends on where you live in

Current Implementation

Each type of reaction has weight which proxies to reactions, then sums up and gives total reaction weight affecting on the reactant.

Reaction.weight = ReactionType.weight

New Implementation

Each type of reaction has mass which proxies to reactions, then sums up and gives total reaction mass affecting on the reactant.

Reaction will have new rate attribute which will increase influence of the reacter on the reactant. Weight in new system is equal to the mass of the reaction type multiplied by the reaction rate.

Reaction.weight = ReactionType.mass * Reaction.rate

Wondering why just not add rate attribute without renaming reaction type weight attribute? Read design process section below for the detailed explanation and difference between weight and mass.

Following changes are required:

  • ReactionType attribute weight will be renamed to mass
  • ReactionType method getWeight() will be renamed to getMass()
  • Reaction will have additional attribute rate

These changes are not mandatory but will increase statistics possibilities:

  • Reaction will have additional method getRate()
  • Reaction will have additional method getMass()
  • ReactionCounter will receive additional attributes mass & rate
  • ReactionCounter will receive additional methods getMass() & getRate()
  • ReactionTotal will have additional attributes mass & rate
  • ReactionTotal will have additional methods getMass() & getRate()

Update console command:

  • php artisan love:reaction-type-add --mass="-1"

Design Process

I was inspired by physics and chemistry while designed new system.

In physics, Reaction Force formula:

force = mass * acceleration

Acceleration is the rate of change of velocity of an object with respect to time.

Let's replace acceleration in this formula with rate:

force = mass * rate

Rate is the velocity of an reactant becoming popular.

Weight is the force caused by gravity:

weight = force * gravity

That means reaction could have different weight depends of reactant location.

Reaction to the post in closed group can weight more than in public group.

Because we don't need gravity operand in weighting formula yet we could define it's default value as 1 so it wouldn't affect on any applications which don't need this feature.

weight = mass * rate * 1

Or even simpler for now:

weight = mass * rate

Future Considerations

Reaction Gravity

Reaction Gravity represents environment around the reactant and will affect on the reaction weight, but it wouldn't affect on net Reaction Force.

Default value: 1.0.
weight = mass * rate * gravity

Reacter Power

Reacter Power represents reserve of strength which could be used to increase rate of the reactions.

Power reserve logic depends on the business requirements, it could be:

  • infinite
  • finite
  • finite but refillable
  • ...

Reaction Force

Reaction Force might be useful for sorting statistical data ignoring the gravity. In current version it's equal to Reaction Weight because we don't have gravity yet.

force = mass * rate

// Note: Reaction Force wouldn't be added until we have real life use case. Write down if you need it.

@antonkomarev antonkomarev added this to the v8.0.0 milestone Jul 27, 2019

@antonkomarev antonkomarev changed the title New weighting reactions system New Weighted Reaction System Jul 27, 2019


This comment has been minimized.

Copy link
Member Author

commented Jul 27, 2019

One important thing we need to decide: will rate be integer or float?

If it will be float - then weight must be float too. It will add complexity to the system, but with it we will be able not only increase, but also decrease the importance of reacter's reactions too.

All reacters will start with rate=1 but then rate of their reactions could be decreased because of their activity. For example when a lot of people downvotes reacter's comments, posts and himself - his future reactions will have rate=0.01 with minimum influence on the reactants.

@antonkomarev antonkomarev changed the title New Weighted Reaction System Weighted Reaction System 2.0 Concept Jul 29, 2019


This comment has been minimized.

Copy link
Member Author

commented Jul 31, 2019

I'm closing this issue. Core logic was implemented in #91.

When we will decide to add some kind of gravity attribute - then it will be next major version of the Weighted Reaction System.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
1 participant
You can’t perform that action at this time.