Posts for mrgiggums

Experienced Forum User
Joined: 6/9/2014
Posts: 3
I've encountered my first major desync. I lost 16 of 19 pieces (and 600 frames). I don't even know how this happened and I could even replicate it.
Experienced Forum User
Joined: 6/9/2014
Posts: 3
I have finished my program and I found out a few things in the process. It turns out that there is a bug in the original tetris code where it is impossible for there to be a garbage tile in the upper left corner in mode B. It is not possible to use every seed after the first available one. This is because the code does not call its random function evenly. To solve this I ran a lua script that found all possible seeds waiting a maximum of 100 frames. I then took these seeds and put them in a java program to generate the garbage pattern. I took all the seeds where (tiles % 4 == 2) and analyzed them for how many line clears it would take to clear the garbage pattern. My algorithm is not perfect (I didn't spend much time on it) and will not generate totally accurate numbers, but they usually are correct. Here are my results:
Seed=8e2d	wait frames=0 	# of tiles=46	clear anim=11
Seed=21eb	wait frames=10	# of tiles=58	clear anim=11
Seed=9948	wait frames=12	# of tiles=54	clear anim=10
Seed=2652	wait frames=13	# of tiles=54	clear anim=10
Seed=a265	wait frames=14	# of tiles=54	clear anim=11
Seed=3a26	wait frames=15	# of tiles=54	clear anim=10
Seed=c744	wait frames=16	# of tiles=50	clear anim=10
Seed=1a0e	wait frames=19	# of tiles=54	clear anim=11
Seed=4341	wait frames=20	# of tiles=54	clear anim=10
Seed=2028	wait frames=23	# of tiles=50	clear anim=10
Seed=840	 wait frames=25	# of tiles=54	clear anim=10
Seed=9021	wait frames=27	# of tiles=54	clear anim=10
Seed=1e64	wait frames=34	# of tiles=50	clear anim=10
Seed=8f32	wait frames=35	# of tiles=54	clear anim=10
Seed=4b4f	wait frames=42	# of tiles=54	clear anim=10
Seed=bdc4	wait frames=53	# of tiles=50	clear anim=9
Seed=2f71	wait frames=54	# of tiles=50	clear anim=9
Seed=e00b	wait frames=57	# of tiles=58	clear anim=11
Seed=bd78	wait frames=60	# of tiles=62	clear anim=12
Seed=fe2b	wait frames=62	# of tiles=54	clear anim=10
Seed=6773	wait frames=74	# of tiles=62	clear anim=12
Seed=14ce	wait frames=75	# of tiles=50	clear anim=12
Seed=d14c	wait frames=76	# of tiles=50	clear anim=12
Seed=e768	wait frames=79	# of tiles=58	clear anim=12
Seed=8c37	wait frames=86	# of tiles=50	clear anim=11
Seed=a376	wait frames=90	# of tiles=50	clear anim=11
Seed=d546	wait frames=91	# of tiles=54	clear anim=12
Seed=724e	wait frames=94	# of tiles=54	clear anim=11
Seed=ce49	wait frames=95	# of tiles=54	clear anim=12
Seed=79c9	wait frames=96	# of tiles=50	clear anim=11
Seed=c3ce	wait frames=97	# of tiles=54	clear anim=11
Note that the 2652 seed was that seed that baxter used for his TAS.
Seed=8e2d   wait frames=0    # of tiles=46   clear anim=11    benefits=Has zero wait frames
Seed=21eb   wait frames=10   # of tiles=58   clear anim=11    benefits=Starts with 58 garbage tiles
Seed=9948   wait frames=12   # of tiles=54   clear anim=10    benefits=Has 10 line animations and low wait frames
Seed=2652   wait frames=13   # of tiles=54   clear anim=10    benefits=Has 10 line animations and low wait frames
Seed=bdc4   wait frames=53   # of tiles=50   clear anim=9     benefits=Has 9 line animations but more wait frames
Seed=2f71   wait frames=54   # of tiles=50   clear anim=9     benefits=Has 9 line animations but more wait frames
These are probably the fastest six. I have also made the java program display an image of what it would look like. Here are the six seeds above with the lowest wait frames first: EDIT: Here is my java code for generating the garbage pattern. It isn't written the best but it works.
	void generateSeed() {
		for(curRow = 0x0C; curRow!=0; curRow--){
			rowOffsetIndex = (byte) (0x0C - curRow);
			for(curColumn = 0x09; curColumn>=0; curColumn--){
				rand();
				wellMem[10*rowOffsetIndex + curColumn] = (byte) tileArray[rand17 & 0x07];
			}
			do{
				rand();
			}while((rand17 & 0x0F) >= 0x0A);
			wellMem[10*rowOffsetIndex + (rand17 & 0x0F)] = 0;
			rand();
		}
		wellMem[0] = 0;
	}
	
	void rand() {
		rand = ((((rand >> 9) & 1) ^ ((rand >> 1) & 1)) << 15) | (rand >> 1);
		rand17 = (byte) (rand >> 8);
	}
Experienced Forum User
Joined: 6/9/2014
Posts: 3
I am new to TAS and I have decided to attempt to beat the mode B 19-5 run. My first attempt I did blind without looking anything up. It resulted in 2775 frames or 46.25 seconds as compared to the record at 2331 frames or 38.85 seconds. Considering it was my first TAS I don't think it was too bad. I realized upon review that I wasted a lot of time with single line clears. Then I decided to do a little research when I stumbled upon this thread. I have read the discussion of testing seeds to find a good garbage pattern. Although I am new to TAS, I have a little of experience with assembly. So I have been poking through the disassembled code in the hopes of creating a program to find the best seeds. I will post more as I figure out more but for now I believe I have located the code that generates the garbage patterns if anyone is interested to try for themselves.
00:87E3:A9 0C     LDA #$0C      ;initialize values
00:87E5:85 A8     STA $00A8     
00:87E7:A5 A8     LDA $00A8     ;loops here for next row
00:87E9:F0 5F     BEQ $884A     
00:87EB:A9 14     LDA #$14      
00:87ED:38        SEC           
00:87EE:E5 A8     SBC $00A8     
00:87F0:85 A9     STA $00A9     
00:87F2:A9 00     LDA #$00      
00:87F4:85 69     STA $0069     
00:87F6:85 89     STA $0089     
00:87F8:A9 09     LDA #$09      
00:87FA:85 AA     STA $00AA     
00:87FC:A2 17     LDX #$17      ;loop here for next column
00:87FE:A0 02     LDY #$02      
00:8800:20 47 AB  JSR $AB47     ;generate next random value
00:8803:A5 17     LDA $0017     
00:8805:29 07     AND #$07      
00:8807:A8        TAY           
00:8808:B9 7C 88  LDA $887C,Y   ;get a random tile
00:880B:85 AB     STA $00AB     
00:880D:A6 A9     LDX $00A9     
00:880F:BD D6 96  LDA $96D6,X   ;get row offset
00:8812:18        CLC           
00:8813:65 AA     ADC $00AA     
00:8815:A8        TAY           
00:8816:A5 AB     LDA $00AB     
00:8818:99 00 04  STA $0400,Y   ;store tile in memory
00:881B:A5 AA     LDA $00AA     
00:881D:F0 05     BEQ $8824     
00:881F:C6 AA     DEC $00AA     
00:8821:4C FC 87  JMP $87FC     ;loop until row is finished
00:8824:A2 17     LDX #$17      
00:8826:A0 02     LDY #$02      
00:8828:20 47 AB  JSR $AB47     ;generate next random value
00:882B:A5 17     LDA $0017     
00:882D:29 0F     AND #$0F      
00:882F:C9 0A     CMP #$0A      
00:8831:10 F1     BPL $8824     ;loop until (rand & #$0F) < #$0A
00:8833:85 AC     STA $00AC     
00:8835:A6 A9     LDX $00A9     
00:8837:BD D6 96  LDA $96D6,X   
00:883A:18        CLC           
00:883B:65 AC     ADC $00AC     
00:883D:A8        TAY           
00:883E:A9 EF     LDA #$EF      
00:8840:99 00 04  STA $0400,Y   ;set random block in row to an empty tile
00:8843:20 2F AA  JSR $AA2F     
00:8846:C6 A8     DEC $00A8     
00:8848:D0 9D     BNE $87E7     ;loop until all rows are done