[ 3 / biz / cgl / ck / diy / fa / ic / jp / lit / sci / vr / vt ] [ index / top / reports ] [ become a patron ] [ status ]
2023-11: Warosu is now out of extended maintenance.

/sci/ - Science & Math


View post   

File: 25 KB, 650x638, 1521469512317.png [View same] [iqdb] [saucenao] [google]
10605704 No.10605704 [Reply] [Original]

how do u make a function that takes an HP value and the lower it gets the more priority it gives?

like I want to set my chess piece move priority with how much HP the enemy piece has multiplied by how low it's HP is.

/g/ told me to fuck off here.

I just want to make a shitty chess clone in godot.

>> No.10605713

>>10605704
bro reformulate your question
this is just incoherent

>> No.10605719

>>10605713
I have to calculate what the damage score of a certain move in my chess clone.

I can calculate and get the enemy píece ID and set a basic formula to calculate it's priority.
that's easy.

I want now to take into account the piece HP and multiply the piece priority by how near it's HP is to 0.

>> No.10605724

>>10605704
Give it infinity HP

>> No.10605734

>>10605719
How the fuck is that hard?? It's basic arithmetic.

Just take the ratio HP / Max_HP and make up your own function with that as the input, give a result, and then multiple the priority by it.

>> No.10605737
File: 47 KB, 650x773, 1520380041734.png [View same] [iqdb] [saucenao] [google]
10605737

>>10605734
I'm a guy at /vg/ using a game engine, not a math guy.

would you give me some kind of code for this pls?

>> No.10605752

>>10605737
Anon. Bro. Come on. You can't divide or multiply two numbers in code?

>> No.10605756

>>10605752
var ratio = HP / Max_HP

var priority = piece[id].priority * ratio

Is this what you're talking about?

What's a ratio anyway?

>> No.10605762

>>10605704
Are you a guy that made shogi clone with hp bar?

>> No.10605766

>>10605762
yes.

trying to get the AI done.

>> No.10605768

>>10605756
That's exactly it. Or

var ratio = (1 - HP/Max_HP)

if you want the prio to be higher if closer to zero HP.

>> No.10605771

>>10605768
can u explain to me how it gets bigger if closer to 0?

>> No.10605773

>>10605771
plug in some numbers and figure it out

>> No.10605774

>>10605771
holy shit anon

>> No.10605775

>>10605771
You want us to explain how remedial math works?

>> No.10605776

>>10605773
>>10605774
>>10605775
just give me the name of the wikipedia page about it, I wanna know beyond copy pasting code.

I don't know nothing more than aritmetic.

>> No.10605779

>>10605776
https://en.wikipedia.org/wiki/Affine_transformation

>> No.10605780

>>10605771
>>10605776
Are you in first grade because if not, jesus christ anon!?

>> No.10605783

>>10605779
thanks.

>>10605780
school dropout making a game.

>> No.10605849

>>10605704
ah-bloo-bloo

>> No.10606431

>>10605783
This is upsetting, good luck anon. Go to khan academy it’s free online math lessons

>> No.10606449

>>10605783
Here’s a math lesson for the future of your life no matter what you do.
If you’re unsure where to start, just start plugging in some numbers. If you can’t do basic shit like that to get yourself started then game development will eat you alive.