EDT 13:24 CEST 19:24 KST 02:24

Streams: 119 live
73978 total viewers

Active: 9841
Pizza Meter
[WCS AM] Ro16 Group B Prev…
WCS AM - Ro16 Interviews a…
AMD Premier League S1 Gran…
[WCS KR] Semis: Soulkey vs…
[WCS AM] Premier League Ro…
LGD.cn and RaTtLeSnAkE Adv…
GomTV: about the gamespeed…
Papa John's explores EG, L…
TeamLiquid Map Contest Fin…
Liquid wins the Curse Invi…
mousesports defeats DD.Dot…
Dragon joins Clarity Gaming
New Get 50% off Papa Joh…
TL Advertising Features
New XBOX reveal May 21st
[TV] Star Trek: Deep Spa…
[Manhwa/Manga] Tower of …
Best way to "move on" af…
GeoGuessr geography game
The Automated Ban List
2013 Philadelphia Starcraf…
Left Sidebar Customization
Houston Barcraft
G-1 Grand Finals Meetup
The Liquid`TLO Fanclub
The IdrA Fanclub
[Stream] Techstarcraft2
[Stream] Terrorterran
Recent Twitch.TV iPhone Up…
Shift button buggy while s…
Computer Build Resource Th…
Any fix for Twitch tv lag?
Mechanical Keyboard Guide
Incredible Miracle spons…
WCS AM - Ro16 Interviews…
Papa John's explores EG,…
GomTV: about the gamespe…
HotS race distribution o…
Fantasy GSTL: HotS Seaso…
[WCS EU] Challenger League…
BO7 Challenger Series 200€
Revive Your Energy Starlea…
[Code S] Placement Matches…
[Code S] RO4 Day 1 WCS Kor…
The HotS Terran Help Me Th…
[G] NaNiwa's PvZ (vs HyuN)…
The HotS Zerg Help Me Thread
[H] ZvP Need help
Simple Questions Simple An…
[M] (8) Crux Breeze
[TLMC] Originality Selecti…
OneGoal: A better SC2 [Pro…
[M] (4) TPW Strangewood Mire
[D] Favorite Maps that Did…
General Discussion
Dota 2 QQ thread
Inhouse Dota
LGD.cn and RaTtLeSnAkE A…
AMD Premier League S1 Gr…
TL's Item Trading Thread.
Starladder Season 6
[The International] Easter…
Liquid Pasture Community L…
Sticky Flames Weekly Dota …
We are giving away Season …
Simple Questions, Simple A…
Drafting, my thoughts on it
Solo Mid - Who? What? How?
A guide to Krobelus, the D…
Newly ported Hero discussi…
Pucca Comeback?
SC2 Player looking to le…
DES Sonic Interview 5/18…
[TLS2] Qualifier #4 VODs
BW Liquibet Season 25
sAviOr vs NaDa
[TLS2] Qualifier #4
Gem League II
[GC S3] Gambit's Cup Semif…
Torenhire Starleague II
D Ranks Teamleague Season 4
Challenger map on Starcraf…
Simple Questions, Simple A…
Increasing APM/EAPM
Tips and tricks: Defilers …
EVE Corporation
2012 - 2013 Football Thr…
FIFA Thread! (PC - Xbox …
World of Tanks
NBA Playoffs 2013
[Patch 3.07: Nerf Everythi…
Anyone Diamond want to joi…
[LoL] [SFW] Random Pics & …
[OGN] Olympus The Champion…
[LoL] General Stream Thread
[D] Pro Scene Evolution
[Champion] Swain
[Guide] Montegomery's Supe…
[Champion] Ezreal
The: What is my item worth?
Selling Items Thread
Witch Doctor Discussion
Carnival Cruise Mafia
[M][N] Les Mafia
[T] Bastard "Mini" Mafia!
TL Health and Fitness Init…
Running Thread
Questions & Answers
Leta - Movie
Michael - skyline
Anytime - Beast
By.Hero - Shuttle
Anytime - Pusan

Website Feedback

Closed Threads

IRC Chat
irc.quakenet.org #teamliquid

IRC Web Client

TeamSpeak 3 (86 users)

Math in Games

Forum Index > Blogs
  micronesia   United States. April 23 2011 01:44. Posts 19310Profile Blog # 
I've always thought it's cool to take what you've learned about math (in school, etc) and apply it to real life. By real life of course I'm talking about video games (well, REAL life too, but I'm just gonna talk about games now). I just had one of these moments so I figured I'd share it.

Recently I've been playing through Vagrant Story, which is a great game by the way. When you attack you have the option to chain multiple hits together, one after the other. So let's say you attack and deal 10 damage... you can just stop there or you can try to get a second attack in on the same 'turn.' You need to time the button press right in order to get the second hit, but if you do then he'll do additional damage.

I'm going to simply the system a bit. Technically this isn't exactly how it works, but for the sake of discussion: if you deal 10 damage on the first attack, the you'll deal 12 on the second attack. You'll deal 14 on the third attack, etc. In case you are wondering... yes there is a reason not to just always chain the maximum amount of attacks together you can: your "risk" goes up as you use chain abilities making your accuracy go down. This doesn't affect the upcoming calculation but should explain why chaining to infinity is not always preferable.

Time to apply what I've learned previously about sequences and series to this situation... the amount of damage Ashley (the main character) deals after one hit is A (let's say). The first time he attacks we'll call the 0th attack (the first chain attack would be n=1, etc). The amount of damage he does on a given attack is:

A+2n

so if it was the third attack (second chain attack) then he would deal A+6 damage. The total amount of damage he has dealt from the first attack through the nth attack is:

SUM from 0 to N of A+2n

where N is the last attack of the chain. So if Ashley attacks once, does 10 damage, then attacks two more times, the total damage is 10+12+14 = 36. In order to get the general formula for how much damage is dealt in total in N+1 turns, we need to solve that summation. First, I split it into two separate summations which you can do when summing the addition of two terms:

SUM from 0 to N of A plus SUM from 0 to N of 2n

The left sum I will solve in one step. The right sum I will start by pulling out the coefficient of 2:

(N+1)A plus 2*SUM from 0 to N of n

You might recall the famous math problem (what is the sum of all integers from 0 to 100). We use the result of that to solve the remaining summation. Read the spoiler for background.

+ Show Spoiler [background of sum of 1 to 100] +

Solving the right summation we get:

(N+1)A plus 2*( [0+N]/2 * [n+1] )

Manipulating the expression:

AN + A + N^2 + N

Manipulating a bit more:

A + N(A+N+1)

Let's test this expression out with the earlier example of attacking for 10 damage, and then doing two follow up attacks. A=10, N=2 so:

damage = 10 + 2(10+2+1) = 36 (correct)


Sample Problem
An enemy boss has 400 HP. Ashley's first attack does 10 damage. How many times will Ashley need to chain attack in order to kill the boss?

A + N(A+N+1) >= HP
10 + N(11+N) >= 400
N^2 + 11N - 390 >= 0 (notice we are applying that cute inequality stuff most of us learned years ago)

N=15

Check: 10+12+14+16+18+20+22+24+26+28+30+32+34+36+38 = 400

Therefore, after the initial attack, Ashley will need to chain 15 times. The total number of attacks of that turn would be 16, however.


Practically, this doesn't save you that much time over just using trial and error with the math method used in the 'check' above. The real power of using formulation rather than calculator work is for extreme cases.


Question 1
Ashley deals 5 damage on this first attack, and follows up with 200 chain attacks. How much damage does this deal?

Question 2
Ashley deals 5 damage on his first attack and needs to kill a boss with an HP of 1,000,000. How many chain attacks will it take?


Challenge:
As I said at the beginning, this is not technically how Vagrant story works. There are different chain abilities that you can use depending on what you've unlocked and how you set your character. After the initial attack you can use 'heavy shot' which deals only 70% of the damage the initial attack did. Alternately, you can use temper which deals 40% of the damage of the initial attack. You can't use the same chain ability twice in a row so you could alternate between heavy shot and temper (temper also restores DP to weapons but we aren't talking about that). The increment of two damage only happens every OTHER chain attack after the first chain attack. So if you deal 100 damage with your first attack, then you will deal 70 with a heavy shot, 40 with a temper, then 72 wit a heavy shot, 42 with a temper, 74 with a heavy shot, 44 with a temper, etc (I'm not 100% sure I have it exactly correct but that's gotta be close). If anyone comes up with a general formula for total damage dealt after N chain attacks if the odd chain attacks are heavy shots and the even chain attacks are tempers then I'll be very impressed... I haven't tried it yet so I'm not sure how difficult it is.

***
Haste. Exalted. Flying. Deathtouch. Lifelink. Protection from Red.
Old Post

 
 Rayeth   United States. April 23 2011 02:06. Posts 535
Profile Blog # 
I have no intention of taking on the questions or the challenge, but I want to say that I totally love Vagrant Story. That was such an underrated game from the PS1 era. Really happy to see people still playing it and giving it the respect it deserves.
The Innocent shall suffer... big time.
Old Post

  micronesia   United States. April 23 2011 02:08. Posts 19310Profile Blog # 

On April 23 2011 02:06 Rayeth wrote:
I have no intention of taking on the questions or the challenge, but I want to say that I totally love Vagrant Story. That was such an underrated game from the PS1 era. Really happy to see people still playing it and giving it the respect it deserves.

Yeah I actually got it when it came out and didn't fully appreciate it. A few years ago I played it some more and appreciated it. This time I love it.

It just gets better and better lol

Was considering making some leather hoplite armor and a wood hoplite shield but it's just too annoying to farm leather.
Haste. Exalted. Flying. Deathtouch. Lifelink. Protection from Red.
Old Post

 
 agarangu   Chile. April 23 2011 02:14. Posts 273
Profile Blog # 
Interesting read, although I never heard about that game.

BTW, the other day I was trying to determine the winner between two groups of units in Starcraft BW, because I wanted to know why a FD worked, and I came up with this formula:

Uf = Ui - ([Vi]*(Vdamage-Uarmor))/(Uhp*Vcooldown)

Where U and V are homogeneous groups of units, f stands for "final number of units" and i for "initial number of units". This formula calculates the total damage in a round, and if you iterate it (I programmed it in Java) it can determine which group wins. The [Vi] part stands for math.ceil, not math.floor, because a damaged unit still fires during a round.

Of course, the damage count can only be precise in TvT (because Z and P regenerate hp/shields) and It doesn't take damage type or unit size into consideration. It's doesn't consider micro or range ether, and damage is calculated as if it were optimal (exact amount of damage to kill one unit).

I know it can be improved, but it helps a lot to know how many rines do I need to kill two goons.

edit: oh, I almost forgot, the game
Last edit: 2011-04-23 02:16:20
What's a quote anyway?
Old Post

 
 wooozy   April 23 2011 02:18. Posts 1655
Profile Blog # 
i'm with that first guy. no intention of doing the questions/challenges, but man, vagrant story is a great game. probably up there in my top 3 of favorite ps1 games next to xenogears
Old Post

 
 Seth_   Belgium. April 23 2011 02:45. Posts 184
Profile Blog # 
challenge:
+ Show Spoiler +
Last edit: 2011-04-23 02:47:31
Old Post

 
 G3CKO   Canada. April 23 2011 05:39. Posts 1086
Profile Blog # 
You can map anything into differential equations, including StarCraft.
┌⋉⊳∀⊲) ☆ If your soul has not truly given up, then you can hear the sound that races through the end of the world.
Old Post

  micronesia   United States. April 23 2011 05:44. Posts 19310Profile Blog # 

On April 23 2011 05:39 G3CKO wrote:
You can map anything into differential equations, including StarCraft.

Can you give examples? Are you exaggerating by saying 'everything'?
Haste. Exalted. Flying. Deathtouch. Lifelink. Protection from Red.
Old Post

 
 G3CKO   Canada. April 23 2011 05:56. Posts 1086
Profile Blog # 

On April 23 2011 05:44 micronesia wrote:

Show nested quote +


Can you give examples? Are you exaggerating by saying 'everything'?


The rate of income vs. worker count. I can actually work this out give me a few minutes as I haven't done diffiques in a while. Differential equation is essentially how the world works you could say.
Last edit: 2011-04-23 05:58:50
┌⋉⊳∀⊲) ☆ If your soul has not truly given up, then you can hear the sound that races through the end of the world.
Old Post

 
 ChrisXIV   Austria. April 23 2011 06:07. Posts 2087
Profile Blog # 

On April 23 2011 05:39 G3CKO wrote:
You can map anything into differential equations, including StarCraft.


You sound like one of my professors at university.

"Everything is quantifiable!"

But it's true, make it abstract enough to see numbers and you're good to go. The only difficulty is combining sets.

Starcraft example: 'Efficiency' is a broad term, but if we can somehow combine all inputs like individual unit micro, cost of said units, etc... then we can compare it. ^^

Edit: Spelling T_T
Last edit: 2011-04-23 06:08:09
"Just stay on 1 base, make a lot of shit, keep attacking. It doesn't work? Keep attacking." -Chill
Old Post

 
 igotmyown   United States. April 23 2011 06:36. Posts 2896
Profile Blog # 
Due to the discrete nature of games, differential equations are (sadly) rarely to never useful.

Usually you get highly involved algebra

http://forums.civfanatics.com/showthread.php?t=266397&page=4

+ Show Spoiler +

or

+ Show Spoiler +
Old Post

  micronesia   United States. April 23 2011 06:40. Posts 19310Profile Blog # 

On April 23 2011 06:36 igotmyown wrote:
Due to the discrete nature of games, differential equations are (sadly) rarely to never useful.

Usually you get highly involved algebra

http://forums.civfanatics.com/showthread.php?t=266397&page=4

+ Show Spoiler +

or

+ Show Spoiler +
This was my thinking but I figured I'd give G3CKO his time to shine lol
Haste. Exalted. Flying. Deathtouch. Lifelink. Protection from Red.
Old Post

 
 eviltomahawk   United States. April 23 2011 06:47. Posts 8889
Profile Blog # 

On April 23 2011 05:44 micronesia wrote:

Show nested quote +


Can you give examples? Are you exaggerating by saying 'everything'?

Apparently, the UC Berkeley Starcraft class had some pretty crazy math going on in it. I think one of the recommended prerequisites was Differential Calculus, but I can't seem to access the class's site so I can't confirm.
<3 <3 IU Ailee Minzi Gain <3 <3 ㅇㅅㅌㅅ
Old Post

 
 Dave[9]   United States. April 23 2011 06:52. Posts 2337
Profile Blog # 
I've done a few projects for math in games! They are pretty damn fun. I remember one of them being applying markov chains to monopoly in order to figure out what spots you land on the most (and thus rake in the most money) in the long run. Probability and linear algebra can be applied to soooo many board games it's insane. I think I remember seeing another way to use markov chains in Risk as well, I just didnt take an interest in that article because I didnt know the game very well =P

Basically if you're able to classify things into sets, you could probably find out a ton of things that wouldnt usually be obvious combinatorically. If not, you could probably apply a monte carlo type thing to atleast probabilities of things happening.

I love applied math so much sometimes it scares me.
Think I'm a Day[9] wannabe? See this! http://www.teamliquid.net/forum/viewmessage.php?topic_id=104154&currentpage=316#6317
Old Post

 
 Hidden_MotiveS   Canada. April 24 2011 13:45. Posts 2019
Profile Blog # 
I've done a lot of math for games too. The fact that games are discretized, making use of algebra important is very true for games. I think this is a good thing. You shouldn't have to use complex math to have to solve real world problems.

I remember doing a lot of math for age of empires 3 and age of empires 2 (villager second calculations) but overall they weren't a substitute for actually testing out my hypothesis. The nice thing about age of empires is that you're working with such large numbers that things tend to work out like they are continuous so you can model things using calculus pretty accurately.

More often than not, I and other theorists, ended up making tables using basic algebra. There's a saracen market trading table for age of empires 2 on the aoe2 heaven forums. People figured out a way to make saracens get more resources by using a market. Cyclohexane combined and created a lot of knowledge about age of empires 3 into one beautiful quick reference guide.

Math should be used more often in games. Sometimes it's not enough to know that one unit is better than another, you want to be able to mathematically prove it so that you can combat more situations that experience can't teach you. The people who make good timing pushes know exactly how long it takes for upgrades to finish and buildings to build. Even starcraft 2 pros don't use enough math.

I remember hearing commentators talk about how Idra's opponent had more workers on the same number of bases as Idra. They berate him, but they don't look at the saturation charts posted on teamliquid to realize that Idra is effectively mining just as much with his normal workers (mules excluded) as his opponent because his bases are just as saturated on fewer workers. Idra was effectively up the cost of 10 drones, 500 minerals, 10 supply slots (late game), and 10 larva, from what a lesser zerg would be at.

Using math on games can have its limitations though. Sometimes the math gets too complex, so I just run simulations, or mass games to improve.


These days, I'm far more interested in Blackjack, and Poker Theory, because I think it's more applicable. It's unfortunate that there are so many people smarter than me in the world. I know that if there were ways to make lots of money through either blackjack or poker, that they'd be doing it.
Old Post

Please log in or register to reply.
 
Refresh
StarCraft: Brood War
StarCraft 2
Dota 2
League of Legends
Diablo III
[ Show 97 non-featured ]

» Recent SC2 Results
» Premier SC2 Tournaments
Sidebar Settings...

The Little App Factory



The opinions expressed by our users do not reflect the official position of TeamLiquid.net or its staff.

Advertising | Jobs | Privacy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren. Ad tag: TF_US.
The contents of this webpage are copyright © 2002-2013 Teamliquid.net. All Rights Reserved