How to measure the difference between 2 scores without standard maths


#1

If a cpu score is 20, and the players score is 5, the standard way to tell the difference and which score is higher is,
If cpu score is greater than players score, the 20-5 will give "15" the difference.
The same code applies to players score when it's higher.

Recently I coded with an app where you can't use maths to compare a score/value to another.
Like I couldn't code to have the cpu score minus the players score or vice versa.
I figured out a code/simple maths to compare the difference. Like if I always want the cpu to attack the player if the cpu score is 10 points or greater than the players score. I mentioned there's no way to use maths formulas to compare scores/values.

This solution can be used in Hopscotch.
Have 3 values.
Value A(player) Value B(cpu) Value C(difference)

When the player scores 1 point, have Value A go up by 1, Have value C go down by 1 point.
When the cpu scores 1 point, Have Value B go up 1 point, Have value C go up by 1 point.
When Value C is above 0, this shows how much higher the cpu score is above the players score.
When Value C is below 0, this shows how much less the cpu score is below the players score.
@ThinBuffalo
@t1_hopscotch
@Phase_Admin
@Zachyswag
@Valgo
@lollypopcorn


#2

Wow.


#3

Ah, that's awesome! I really like how you used a separate value C there as an alternative way of finding the difference β€” I was curious how you might go about comparing two values without subtracting :thinking: I love seeing creative workarounds like this :grinning:


#4

Why would you need to do this though? Like, talking practicality.


#5

I think here there's no way to subtract the values to compare them


#6

CPU point-human point
Check once if point (less than) 0
Human point- CPU point


#7

But that's another app. This isn't that app.


#8

Or use a check if else block. And also put a repeat forever around it.


#9

It's good to learn new maths formulas.
When everything's not easily pre made or done for the player, this forces the player/creator to use their brains to find alternative solutions to problems.
Like when I once went to KFC and the electronic cash register wasn't working and the cashier couldn't work out the change to give me from a meal costing $28.95, when I gave $30. Nothing new would be discovered if everyone just did things the same way in life.


#10

Seriously!? It's $1.05


#11

Hmm I see your point. I think this is a really creative way of doing it though, and it is possible to do in Hopscotch. It's nice hearing about new ways of approaching things, when you put limitations like no subtraction :slight_smile:

I realised I find creative constraints really interesting too from a few other things. For example, Hopscotch doesn't have arrays, and when I had need for arrays I used a heap of values, and oio, BuildASnowman and others have found ways using clones

Hopscotch doesn't have "repeat until" either but it's possible to do using abilities put inside each other. Other tools take this for granted :slight_smile: A long time ago, Hopscotch didn't even have the multiplication and division operators but someone made a calculator (multiplication is just repeated addition), and I made a basic powers calculator when there was no x ^ y maths bubble (because in the same way, it was repeated multiplication). There are also ways of approximating square roots, I used one of them in a basic square root calculator when there was no square root bubble.

Actually, now that I think of it, division is repeated subtraction and I used that to make a project that works out remainders when dividing numbers. (these projects I'm talking about that I've made are from ages ago; now we have mod for working out remainders)

I don't know, just briefly looking around, I think these sorts of things β€” challenges with limitations β€” are awesome to hear about, they make you think in ways you mightn't have ever considered:

Maybe this one is something we don't have to worry about because we have subtraction in Hopscotch, but it is really interesting to think about – subtraction is something that we just take for granted here. What do you think? :slight_smile:


Oh, do you mean like check if Value A > Value B, that does work too


#12

took me a while after looking around to realise that's basically what I was coming to :joy:


#13

Wow so cool and awesome lol


#14

Great discussion. As often so, impressed by your goals and strategies.
It's not about the solution... it's about the solution. :sunglasses:


#15

Am I the only one who don't get it?
Edit: nvm


#16

Mind blown.

Cool topic @Stradyvarious!


#17

Couldn't you just have value cpu and player and go like this.

When game starts:
Repeat Forever
Check once if player =-10

Because the player would always be at -10when the cpu is at 10.