Post subject: The Technical Aspects of Game Causal Connections
Joined: 3/25/2004
Posts: 459
The number of routes can be represented as: (the number of inputs)^(number of frames). For example, if you only have 3 inputs, after five frames you'll have 3^5 or 243 different input combinations. I was under the impression that the only way to develop a perfect TAS would be to brute force. Imagine a game of Mario 1 where Mario sits still for 3 minutes, and then on the 181st frame you push A and the game glitches to the ending. Of course, this is not the intended means of playing it, and "Mario physics" is irrelevent. The only way to find this very obscure glitch would be through brute force. Now I'm beginning to question this rationale. Of course, a stoned programmer may have added some code to make this strange "teleport to the end" glitch possible, but it's highly unlikely. On the assumption that we have a perfect understanding of the game's code, we would know that this glitch won't occur without even having to test it. But this isn't the reason why we still discuss brute forcing, which leads me to the main point of this thread. In what way are game events causally linked? "P................................................. Q" Imagine that P is a room full of bad guys in Zelda 1, and so is Q. The dots are all the events that occur in between. If we wants to brute force the fastest way to complete room P, we may find that we can save 20 frames by using an extra bomb. Then, when we get to room Q, we brute force that room as well. But, what if it was the case that if you had one extra bomb for room Q, you would have saved 30 frames. Had you known this in room P, you would have chosen the second-fastest route for completing P. I could say that Q is directly related to P. Some aspect stayed (# of bombs) with you which affected the game later down the line. But imagine a game now where each level you start with initial conditions that are uninfluenced by the level before it. (Like, in Mario 1, if you are Super Mario at the end of level 1, you will be Super Mario at the beginning of level 2. Imagine that, regardless of your being Super Mario at the end of level 1, you would begin level 2 small.) ".......P...................|.................Q......" P represents some point in level 1, Q represents some point in level 2, and the | represents the game resetting the memory values to start a new level with some pre-defined initial conditions. Is there anything you can do in level 1 that can affect level 2? I think the only way two events in a game can be causally linked is if there is some shared memory value between the two. If there's not, you can do level 1 as slow as possible, and still be able to do level 2 optimally, even though the start of level 2 begins at a different frame. In other words, regardless of you start level 2 at frame 300 or frame 350, it will still take the same amount of time to complete level 2 optimally. Now, for the roundabout conclusion. We'll call the number of frames from the start of level 1 to the end of level 1 n. We'll call the number of frames from the start of level 2 to the end of level 2 m. Let's presume that this game as only 2 levels, and at the end of level 2, you've beaten the game. Altogether, the number of frames to complete the game is (n+m). Given my introduction, the number of different combinations of inputs would be (number of inputs)^(n+m). However, based on the body of this thread, we could do [(number of inputs)^n + (number of inputs)^m]. This means, rather than having to test ALL possible routes, we only need to test all possible routes for level 1, and then all possible routes for level 2, and then add the shortest route from each together to get the fastest time. This number of combinations is considerably less than doing a brute force of the whole game. Because the number of combinations increases exponentially, doing the brute force of a 5 minute game (like Mario 1) would take a ludicrous amount of time. But, if due to the game's programming elimating any connection between levels, all we have to essentially do is a brute force for every |. This leads me to believe developing the perfect Mario 1 run is achievable without the aid of quantum or relativistic computers. Now, there are some links between levels. Mario's lives, number of coins, and high score, are all variables that transcend levels. However, aren't we fairly certain -- based on our understanding of the game -- that these variables are inconsequential to the behavior of the game? Based on our understanding of the game, we can prune many branches of the gametree. For example, the route which involves Mario dying immediately need not even be considered, because our understanding of the game -- and trust that there were no stoned programmers -- will tell us there's no way for that to result in a faster outcome, so we don't even need to test it. In conclusion (for real), some events in games are not causally connected to previous events do to pre-defined initial conditions of levels and such. To do a brute force, we need only brute force the levels individually, which is a realistic possibility.
Former player
Joined: 3/30/2004
Posts: 1354
Location: Heather's imagination
Assuming we have a perfect route for SMB1 the game can be divided into these sections, lasting (currently) this many frames, rounded up to nearest 5: 1-1 pre-pipe: 195 to 575 = 380 frames 1-1 pipe: 650 to 780 = 130 frames 1-1 post-pipe: 965 to 1295 = 330 frames 1-2: 2490 to 3860 = 1370 frames 4-1: 4000 to 5445 = 1445 frames 4-2 pre-pipe: 6610 to 7225 = 615 frames 4-2 warp zone: 7290 to 7775 = 485 frames 8-1: 7975 to 10385 = 2410 frames 8-2: 11040 to 12445 = 1405 frames 8-3: 13245 to 14615 = 1370 frames 8-4 p1: 15350 to 15890 = 540 frames 8-4 p2: 16045 to 16315 = 270 frames 8-4 p3: 16480 to 16685 = 205 frames 8-4 p4: 16850 to 17545 = 695 frames 8-4 p5: 17720 to 18000 = 280 frames Of course each of these sections can be +/- 20 frames to account for the maximum variation of cutscene length. In the end it's brought 1.44e21674 to a still quite impossible 8.50e2901. An impressive drop of nearly 19 thousand orders of magnitude. But if an entire route were analysed every millisecond it would still take about 10^2888 millenia. Just doing the last section of the last stage (which is most important, as the other sections need to deal with the 21-frame thing) would require 10^323 millenia. For comparison there are something less than 10^90 particles in the universe. Which is about 10^7 millenia old, give or take. (edit: fixed math)
someone is out there who will like you. take off your mask so they can find you faster. I support the new Nekketsu Kouha Kunio-kun.
Patashu
He/Him
Joined: 10/2/2005
Posts: 4045
Maybe once we get some good quantum supercomputers invented we can uber brute-force TASes.
My Chiptune music, made in Famitracker: http://soundcloud.com/patashu My twitch. I stream mostly shmups & rhythm games http://twitch.tv/patashu My youtube, again shmups and rhythm games and misc stuff: http://youtube.com/user/patashu
Joined: 4/4/2004
Posts: 66
The technique of making simplifying assumptions that are likely (but not guaranteed) to hold up and drastically reduce the size of the search space is a common one. Based on my experience with game-playing computer programs, I'd say that you're right - the first attempts at "solving" video games will only solve segments of the games. Actually, I'd say that Bisqwit has already started along this path with his brilliant Rockman-playing program. If you had a solution produced by such a program, you couldn't say that you have proven that your solution is the fastest. However, you could say that you've proven your solution is the fastest assuming that all of your |'s are really |'s (which they probably are, but you don't know for sure). And that's good enough for me (most of the time :)) You may be able to prove that some of your |'s are really |'s without a complete brute-force start-to-finish playthrough. You may be able to produce proof that your |'s are really |'s by looking at the code. Of course, as Boco pointed out, this whole discussion may be nothing more than an interesting theoretical discussion, because the amount of computer power required to solve even small segments is enormous. Many people think that even the game of chess won't ever be solved by computers, and chess only has somewhere between 10^43 and 10^50 legal positions. I'm optimistic, though, and I really hope to see perfect chess and perfect TASes someday :)
Former player
Joined: 3/30/2004
Posts: 1354
Location: Heather's imagination
todd wrote:
Actually, I'd say that Bisqwit has already started along this path with his brilliant Rockman-playing program.
It has already been modified to play SMB. Last I knew it was working on world 3-2, having failed to get warp zone. But it's up to Bisqwit to say what he wants about it outside of the IRC channel. It uses a LOT of simplifying assumptions and only generates soemthing like a few hundred semi-random inputs for any given gameplay second, so it's not really a brute force. But whatever.
someone is out there who will like you. take off your mask so they can find you faster. I support the new Nekketsu Kouha Kunio-kun.
Joined: 9/17/2005
Posts: 47
You'd need a lot of good AI and/or a lot of manual decision-making to make this work in a reasonable amount of time. Bisqwit's approach is the only realistic one I can see.
Editor, Active player (297)
Joined: 3/8/2004
Posts: 7469
Location: Arzareth
Boco wrote:
It has already been modified to play SMB. Last I knew it was working on world 3-2, having failed to get warp zone.
Indeed. It's now in the world 3-3. Besides accidentally doing a walljump occassionally, and stopping against some wall for several seconds, it hasn't yet managed to surprise me (much). It has also jumped through a moving platform once. It hasn't managed to go through a wall yet. Such trick would require it generating very unlikely input, and so far it works only on solutions that are most probable to come up by regular playing (albeit, blind playing). In difficult situations (lots of enemies, or many pits and walls), it sometimes gets stuck for several seconds, because out of the 400 tries it tries, maybe 1-3 manage to resolve the situation, and chances are high that the first 20 frames of those 1-3 tries don't help him actually accomplishing the goal, but the accomplishment incidentally relies in the consequent frames (which were generated only for classifying the quality of the first frames, but which he discards).
Post subject: Re: The Technical Aspects of Game Causal Connections
Joined: 4/3/2005
Posts: 575
Location: Spain
Yes, this exactly is what I was thinking when looking for a way to solve mazes by divide-and-conquer, and my own studies about AI. This is your point. You assume that there is an optimal path between points A and B of a given game. Then, if there is a point in-between, C, in the optimal path, then the optimal path from A to C, and the optimal path from C to B appear in the optimal path from A to B. This property work only if these segments are independent (or just slighty dependent, with some luck), but could be enough for some games. But you must know that some optimal paths do sequence-breaking, so instead of a stream-lined game, you would have a graph (or a labyrinth), in which you could reach the same point from different places. You can't assume beforehand that your optimal path to B will pass from a given point C (just like mazes). You just know that it has to pass from one of the paths that reach B.
 A. To solve this maze:
############
...##....#.#
#.#...##.#.#
#.#.#.#....#
#.#.#.#.####
#...###..#..
#.##...#...#
#....#..####
#.#####....#
############

These two maze must be solvable
A
############
...##....#.#
#.#...##.#.#
#.#.#.#....#
#.#.#.#.####

B
#...###..#..
#.##...#...#
#....#..####
#.#####....#
############
And their solutions must be connected.
Of course, you can keep partitioning the labyrinths until they are trivial problems, and then interconnect them. But this wastes a lot of time solving parts that won't be part of the main solution. On the other side, many computers may work at the same time on different parts of the main problem. Those sub-labyrinths show that there can be multiple solutions to a single segment, but there is maybe only one that can be connected to the next sub-labyrinth. There can be many starts to a single segment, too. In games, this will be starting the segment with different values of: lives left, ammo, starting position, items equipped, etc... So, the same segment must be solven min-maxing those variables until they are no longer solvable: that way, you get the min time needed to pass the segment (wasting any number of resources), and to know the min values required to pass the segment, (though maybe losing time). Some segments are highly dependent of others. For example, there is a trigger in Prince of Persia 2 (PC Game) that creates a skeleton on the bridge that triggers another event which makes you lose your sword. There's a way to pass without activating the trigger, and thus the skeleton is never created. The path to solve that segment changes drastically. If you don't know beforehand about that trigger/glitch, you could end with a sub-optimal path. Note: If you pass the bridge without losing your sword, the next level is a lot more easy. Though, you need to move very quickly in order to pass.
No.
Joined: 3/25/2004
Posts: 459
Boco: The crazy number of combinations was something I didn't realize until I was back in bed. (I typed my OP at, like, 1:30 in the morning.) What inspired me to make the post was the realization that some game events in no way affect other game events. This means we only need to solve segments of the game at a time. But, alas, this is unrealistic also. Another thing I thought up in bed was... Imagine something very simple, like a screen where Samus runs from 1 door the the next. We needed even do brute force, because the optimal path can easily be deduced with mathematics and video game physics. Here's my dictum: "physics" is great when brute force is unrealistic. Brute force is great when "physics" is incalculable. The game I was thinking of last night was Arkanoid. This is definitely a non-liner, maybe even chaotic, game. To solve a level with physics, you would have to calculate the projection of the ball based on the angle, and the resulting consequences. After the ball elimates a block, the whole system has to be reconsidered. Now, if you're working with 2 or 3 balls, you would need to find the right time to optimally hit them all (or some of them) to result in the fastest completion of the level. If brute force were possible, the solution to a very complex physics problem could be solved. In Zelda 1, we could brute force specefic dungeon rooms, particularly those with the blue darknuts, or those with the Patras.
Editor, Active player (297)
Joined: 3/8/2004
Posts: 7469
Location: Arzareth
Ramzi wrote:
In Zelda 1, we could brute force specefic dungeon rooms, particularly those with the blue darknuts, or those with the Patras.
What is the average time required to complete one such room? Can we assume a bomb will only be placed at frames that are evenly divisible by 16? Can we assume Zelda will change facing only at frames that are evenly divisible by 16? Can we assume that two different directions (up+down, diagonals) is not useful to be tried?
Emulator Coder, Skilled player (1311)
Joined: 12/21/2004
Posts: 2687
(I don't think it matters much for a dungeon room when Zelda changes facing...) Do you think it's possible for a brute-forcing or random search algorithm to be modified so that it infers the answers to these questions you asked from the results it gets?
Editor, Active player (297)
Joined: 3/8/2004
Posts: 7469
Location: Arzareth
nitsuja wrote:
Do you think it's possible for a brute-forcing or random search algorithm to be modified so that it infers the answers to these questions you asked from the results it gets?
No, I wasn't thinking of that. I was thinking of ways to decrease the search space.
Emulator Coder, Skilled player (1311)
Joined: 12/21/2004
Posts: 2687
Bisqwit wrote:
No, I wasn't thinking of that. I was thinking of ways to decrease the search space.
Oh, it sounded like you were saying that there are too many assumptions like that that have to be made for a practical solving method to really be "brute force" or general-purpose. But maybe general-purpose isn't what the discussion was focusing on...
Player (80)
Joined: 2/8/2005
Posts: 130
Forgive me if this has already been mentioned or considered, but I just wanted to make clear: if you have 3 inputs for 5 frames isnt it 8^5 input combinations rather than 3^5?
JXQ
Experienced player (761)
Joined: 5/6/2005
Posts: 3132
I thought he meant 3 inputs altogether, not three buttons, just as an example. As far as physics / brute force, an example of something that could throw it off is Mega Man 1. Before discovering all the ways to zip through the game, the solution of a room based on physics may not be even close to fastest. Another small example would be Chip & Dale's apple-glitching, which gains a bit of horizontal forward movement. Anyway, my point is that trying to lower the amount of search space and still have "trust" in the new narrowed brute force algorithm would require extensive game knowledge. Of course, this is the site for that :)
<Swordless> Go hug a tree, you vegetarian (I bet you really are one)
Player (206)
Joined: 5/29/2004
Posts: 5712
I thought Zelda only faced downward, since that's how you find her when you rescue her.
put yourself in my rocketpack if that poochie is one outrageous dude
Joined: 3/25/2004
Posts: 459
Bisqwit wrote:
Ramzi wrote:
In Zelda 1, we could brute force specefic dungeon rooms, particularly those with the blue darknuts, or those with the Patras.
What is the average time required to complete one such room? Can we assume a bomb will only be placed at frames that are evenly divisible by 16? Can we assume Zelda will change facing only at frames that are evenly divisible by 16? Can we assume that two different directions (up+down, diagonals) is not useful to be tried?
My times are conservative. (I added a second if I thought I looked at my system clock late.) I used Sleepz's original run. I timed from the time Link enters the room to the time Link leaves the room. This means, the time to push a block and walk to the secret staircase is also included. 1st blue darknut: 9s 2nd blue darknut: 11s 3rd blue darknut: 6s 4th blue darknut: 7s 1st patra: 12s 2nd patra: 8s What's the significance of it stuff being divisible by 16? And I assume you mean Link. What is the maximum number of frames we can have and still brute force the best route? We should have up, down, left, right, a (for Patra) and up, down, left, right, a, and b (for Darknuts.) There's no need to include Start or Select, as we don't need to change items (if bombs are already set, which we'd do before we enter the room.) This doesn't seem possible at all. In 6 seconds there are 360 frames. 5^360 is too huge to calculate. With our computing capabilities, we can only brute force like 10-12 frames, max.
tool23 wrote:
Forgive me if this has already been mentioned or considered, but I just wanted to make clear: if you have 3 inputs for 5 frames isnt it 8^5 input combinations rather than 3^5?
JXQ said it. Three inputs altogether, not 3 buttons.
JXQ wrote:
As far as physics / brute force, an example of something that could throw it off is Mega Man 1. Before discovering all the ways to zip through the game, the solution of a room based on physics may not be even close to fastest. Another small example would be Chip & Dale's apple-glitching, which gains a bit of horizontal forward movement. Anyway, my point is that trying to lower the amount of search space and still have "trust" in the new narrowed brute force algorithm would require extensive game knowledge. Of course, this is the site for that :)
A long time ago, whe Mario 1 was done in like 5:07, I thought it was perfect because the shorest path was taken and Mario kept max velocity. Certain glitches, such as being able to travel through a wall, allowed this time to be decreased. When I say "physics," I mean all the behavioral rules of the game. I'd say being able to go through the walls is part of Mario physics.
Editor, Active player (297)
Joined: 3/8/2004
Posts: 7469
Location: Arzareth
Ramzi wrote:
What's the significance of it stuff being divisible by 16? And I assume you mean Link.
Yes, I meant Link. The significance is that for a sequence of 8 seconds, there's a HUGE difference if the input can change 480 (8*60) times or if the input can change 30 (8*60/16) times during the sequence. n^30 is a lot smaller number than n^480. for all values of n when n > 1. Basically, decisions like this dictate whether the brute forcing takes 10 years or 10^400 years. :) Exponentiality is annoying, isn't it.
Joined: 3/25/2004
Posts: 459
Hmm... The thought of not being able to place a bomb on a specific frame is something that didn't even occur to me. I wonder why it didn't, it's obvious, and I should have realized it sooner. Or Link changing direction. But why 16? Maybe he can't change his direction every frame, but maybe he can change it every 7 frames. Or every 20 frames. Where did you get 16 from? Also, n^30 is huge. Too huge to calculate. We should find the largest reasonable number of frames and number of inputs, where we can brute force something. And then, we can try to find the rare moments in games where we can apply that brute force. If our computers can do 1000 steps per second, and we can test a route in 1 step, then if we have 1billion routes, we could find the fastest in about 11.574 days. Let's see when brute forcing is possible. (#inputs)^(#frames) = #steps 2^30 = 1,073,741,824 3^19 = 1,162,261,467 4^15 = 1,073,741,824 5^13 = 1,220,703,125 6^12 = 2,176,782,336 7^11 = 1,977,326,743 8^10 = 1,073,741,824 I think I calculated 58 different inputs from the NES controller. God. We would have to really know the right conditions to use a brute force.
Active player (411)
Joined: 3/16/2004
Posts: 2623
Location: America, Québec
How many months will it take to do SMB. LoZ, roflmao, probably 5 years :P