Tag Archives: khan academy

Khan Academy Experiment–Absolute Values

I remember learning about absolute value equations in school. The only thing I retained was that they made V-shaped graphs and that was kind of cool, but I’m not sure I ever grasped an understanding of real-life situations where absolute values came into play.

So here’s an example (special thanks to Matthew DeLucas for suggesting the use case).  It’s extremely simple, but that’s okay because it’s supposed to be for Intro to Algebra stuff (it has some inequalities in there for good measure).  Note, it does not take into account the fact that the stage has bounds, so it’s still an oversimplified case.

You are making a 2D Fighting game (a la Street Fighter).  The part of the screen that is visible is 540 units wide, even though the stage is actually much wider, so you never want your players to be farther away from each other than the width of the visible screen (when players move the screen does not pan up and down, only left and right, so we only care about their positions on the x axis).  When the players get further away from each other than 540 units, the game should push them closer together.

If one player 1’s x position is 100, at what player 2 positions will the game need to push the players towards each other?

|x – 100| = 540

x = –440 or x = 640

image

image

Under what conditions will the game know that it needs to push the players together?

|Player1.x – Player2.x| > 540

|x-y| > 540

image

Khan Academy Experiment–Intro to Algebra

So awhile ago on Facebook, I mentioned wanting to do a thing where I came up with a practical game development example for Khan Academy playlists.  This post is the first one!

I started with the Intro to Algebra playlist, and actually had kind of a tricky time coming up with an example.  I just wanted to do something simple with comparing two linear equations, but lots of things in games don’t end up being linear (the first idea that popped into my head was comparing acceleration and top speed between Bowser and Yoshi and seeing when Yoshi would overtake Bowser, but those aren’t linear rates).

After cycling through some more too-complex ideas, I settled on Gold Drip in MOBA games.  It’s a start, but even still it’s oversimplified for a few reasons

  • It doesn’t take into account other means of gold income or spending, only passive gold drip. 
  • It doesn’t address that you can’t actually buy the Philosopher’s Stone at the beginning of the game – that you can’t have negative gold
  • The per-10-seconds language would have tripped me up as a beginning algebra student, I think.

Anyway, it’s a start.  Please let me know if I blew the math anywhere.

The Scenario

In League of Legends, players earn money at a rate of 16 gold every 10 seconds and every player starts out with 475 gold.  A player can buy an item (Philosopher’s stone) for 700 gold that increases her income by 5 gold per 10 seconds.

So, normal rate (where s is seconds)

Total Gold = (16/10)s + 475

Philosopher’s Stone rate

((16+5)/10)s + 475 – 700

If a player buys the Philosopher’s Stone, at what time does she break even, after which her gold will overtake an opponent who did not buy the Philosopher’s Stone?  This is assuming neither player buys anything else or gains gold in another way.

(16/10)s +475 = ((16+5)/10)s + 475 – 700

(16/10)s +700= ((16+5)/10)s

(16/10)s+700 = (21/10)s

700 = (5/10)s

700=(1/2)s

1400 = s (so 23 minutes and 20 seconds)

IntroToAlgebra

However, this would assume that you could buy the item from the very start and have negative gold.  How long would it take before a player could afford to buy a Philosopher’s stone?

s = (700 – 475) * 10 / 16

Let’s assume that you the designer want the Philosopher’s Stone to be OP  and pay itself off 5 minutes earlier than it does right now (s=1100 instead of s=1400).  How could you change the item’s cost to achieve this?  How could you change its gold gain rate to achieve this?

Changing initial item cost

(16/10)(1100) +475 = ((16+5)/10)(1100) + 475 – c

(16/10)(1100) =  ((21)/10)(1100) – c

1760 = 2310 – c

c = 550

Changing item’s gold gain rate

(16/10)(1100) +475 = ((16/10)+r)(1100) + 475 – 700

1760= 1760+1100r – 700

700 = 1100r

7/11 = r (this is 7 gold per 11 seconds)