Skip to main content
Fixed byte count
Source Link
lirtosiast
  • 21.5k
  • 5
  • 52
  • 127

TI-BASIC, ~10596 bytes (87 for non-competing entry)

For your TI-84 series graphing calculator (!). ThereThis was quite a challenge, because there is no easy way to dowrite a buffered graphics routine (definitely nothing built in), and the graph screen has only four relevant graphics commands: Pxl-On(), Pxl-Off(), Pxl-Change(), and pxl-Test(). 

Uses every accessible pixel on the screen, and wraps correctly. Each cell is one pixel, and the program updates line by line horizontally to the right across the screen. Because the calculators have only a 15MHz z80 processor and BASIC is a slow interpreted language, the code only gets one frame about every five minutes.

  • I use the clock state as a flag. At the start of the program, the date/time clock is enabled, and I use the value of the global isClockOn flag to determine whether it is the first iteration. After the first frame is drawn, I turn the clock off. Saves one byte over the shortest other method and about four over the obvious method.

  • I store the states of the three columns next to the one being updated in a 63-element array of base-7 numbers. The 49's place holds the column to the right, the 7's place holds the middle column, and the units place holds the left column--1 for a live cell and 0 for a dead cell. Then I take the remainder mod 6 of the sum of the three numbers around the cell being modified to find the total number of live neighbor cells (it's just like the divisibility by 9 trick—in base 7, the remainder mod 6 equals the sum of the digits). Saves about 10 bytes by itself and gives the opportunity to use the next two optimizations. Example diagram (let's say there is a glider centered at a certain column at Y=45:

      Row # | Cell State       | Stored number | Mod 6 = cell count
      ...
      44      Live, Live, Live   49+7+1 = 57     3
      45      Dead, Dead, Live   49+0+0 = 49     1
      46      Dead, Live, Dead   0+7+0  = 7      1
      ...
    

    The center cell will stay dead, because it is surrounded by exactly five live cells.

  • After each row is completed, the numbers in the array are updated by dividing the existing numbers by 7, discarding the decimal part, and adding 49 times the values of the cells in the new column. Storing all three columns each time through would be much slower and less elegant, take at least 20 more bytes, and use three lists rather than one, because the values of cells in each row must be stored before cells are updated. This is by far the smallest way to store cell positions.

  • The snippet int(3fPart(3cosh( gives 1 when the input equals 3/6, 2 when it equals 4/6, and 0 when it equals 0, 1/6, 2/6, or 5/6. Saves about 6 bytes.

Exact byte count and aditional explanation coming soon.

TI-BASIC, ~105 (87 for non-competing entry)

For your TI-84 series graphing calculator (!). There is no easy way to do buffered graphics, and the graph screen has only four relevant graphics commands: Pxl-On(), Pxl-Off(), Pxl-Change(), and pxl-Test(). Uses every accessible pixel on the screen, and wraps correctly. Each cell is one pixel, and the program updates line by line horizontally to the right across the screen. Because the calculators have only a 15MHz z80 processor and BASIC is a slow interpreted language, the code only gets one frame about every five minutes.

  • I use the clock state as a flag. At the start of the program, the date/time clock is enabled, and I use the value of the global isClockOn flag to determine whether it is the first iteration. After the first frame is drawn, I turn the clock off. Saves one byte over the shortest other method and about four over the obvious method.

  • I store the states of the three columns next to the one being updated in a 63-element array of base-7 numbers. The 49's place holds the column to the right, the 7's place holds the middle column, and the units place holds the left column--1 for a live cell and 0 for a dead cell. Then I take the remainder mod 6 of the sum of the three numbers around the cell being modified to find the total number of live neighbor cells. Saves about 10 bytes by itself and gives the opportunity to use the next two optimizations. Example diagram (let's say there is a glider centered at a certain column at Y=45:

      Row # | Cell State       | Stored number | Mod 6 = cell count
      ...
      44      Live, Live, Live   49+7+1 = 57     3
      45      Dead, Dead, Live   49+0+0 = 49     1
      46      Dead, Live, Dead   0+7+0  = 7      1
      ...
    

    The center cell will stay dead, because it is surrounded by exactly five live cells.

  • After each row is completed, the numbers in the array are updated by dividing the existing numbers by 7, discarding the decimal part, and adding 49 times the values of the cells in the new column. Storing all three columns each time through would be much slower and less elegant, take at least 20 more bytes, and use three lists rather than one, because the values of cells in each row must be stored before cells are updated. This is by far the smallest way to store cell positions.

  • The snippet int(3fPart(3cosh( gives 1 when the input equals 3/6, 2 when it equals 4/6, and 0 when it equals 0, 1/6, 2/6, or 5/6. Saves about 6 bytes.

Exact byte count and aditional explanation coming soon.

TI-BASIC, 96 bytes (87 for non-competing entry)

For your TI-84 series graphing calculator (!). This was quite a challenge, because there is no easy way to write a buffered graphics routine (definitely nothing built in), and the graph screen has only four relevant graphics commands: Pxl-On(), Pxl-Off(), Pxl-Change(), and pxl-Test(). 

Uses every accessible pixel on the screen, and wraps correctly. Each cell is one pixel, and the program updates line by line horizontally to the right across the screen. Because the calculators have only a 15MHz z80 processor and BASIC is a slow interpreted language, the code only gets one frame about every five minutes.

  • I use the clock state as a flag. At the start of the program, the date/time clock is enabled, and I use the value of the global isClockOn flag to determine whether it is the first iteration. After the first frame is drawn, I turn the clock off. Saves one byte over the shortest other method and about four over the obvious method.

  • I store the states of the three columns next to the one being updated in a 63-element array of base-7 numbers. The 49's place holds the column to the right, the 7's place holds the middle column, and the units place holds the left column--1 for a live cell and 0 for a dead cell. Then I take the remainder mod 6 of the sum of the three numbers around the cell being modified to find the total number of live neighbor cells (it's just like the divisibility by 9 trick—in base 7, the remainder mod 6 equals the sum of the digits). Saves about 10 bytes by itself and gives the opportunity to use the next two optimizations. Example diagram (let's say there is a glider centered at a certain column at Y=45:

      Row # | Cell State       | Stored number | Mod 6 = cell count
      ...
      44      Live, Live, Live   49+7+1 = 57     3
      45      Dead, Dead, Live   49+0+0 = 49     1
      46      Dead, Live, Dead   0+7+0  = 7      1
      ...
    

    The center cell will stay dead, because it is surrounded by exactly five live cells.

  • After each row is completed, the numbers in the array are updated by dividing the existing numbers by 7, discarding the decimal part, and adding 49 times the values of the cells in the new column. Storing all three columns each time through would be much slower and less elegant, take at least 20 more bytes, and use three lists rather than one, because the values of cells in each row must be stored before cells are updated. This is by far the smallest way to store cell positions.

  • The snippet int(3fPart(3cosh( gives 1 when the input equals 3/6, 2 when it equals 4/6, and 0 when it equals 0, 1/6, 2/6, or 5/6. Saves about 6 bytes.

Improved explanation
Source Link
lirtosiast
  • 21.5k
  • 5
  • 52
  • 127

TI-BASIC, ~105 (87 for non-competing entry)

0
While 1
For(X,0,93
Ans/7+49seq(pxl-Test(Y,X+1),Y,0,62
For(Y,1,61
If 2rand>isClockOn=pxl-Test(Y,X)+int(3fPart(3cosh(fPart(6ֿ¹iPart(sum(Ans,Y,Y+2
Pxl-Change(Y,X
End
End
ClockOff
End

This version is probably the most golfed code I have ever written, and contains some truly nasty obfuscatory optimizations:

  • I use the clock state as a flag. At the start of the program, the date/time clock is enabled, and I use the value of the global isClockOn flag to determine whether it is the first iteration. After the first frame is drawn, I turn the clock off. Saves one byte over the shortest other method and about four over the obvious method.

  • I store the states of the three columns next to the one being updated in a 63-element array of base-7 numbers. The 49's place holds the column to the right, the 7's place holds the middle column, and the units place holds the left column-- in each element, they're always 11 for a live cell and 0 for a dead cell, so an example array element may be 49+7+0=56. Then I take the remainder mod 6 of the sum of the three numbers around the cell being modified to find the total number of live neighbor cells. Saves at least 20about 10 bytes by itself and gives the opportunity to use the third optimizationnext two optimizations. Example diagram (let's say there is a glider centered at a certain column at Y=45:

      Row # | Cell State       | Stored number | Mod 6 = cell count
      ...
      44      Live, Live, Live   49+7+1 = 57     3
      45      Dead, Dead, Live   49+0+0 = 49     1
      46      Dead, Live, Dead   0+7+0  = 7      1
      ...
    

    The center cell will stay dead, because it is surrounded by exactly five live cells.

  • After each row is completed, the numbers in the array are updated by dividing the existing numbers by 7, discarding the decimal part, and adding 49 times the values of the cells in the new column. Storing all three columns each time through would be much slower and less elegant, take at least 20 more bytes, and use three lists rather than one, because the values of cells in each row must be stored before cells are updated. This is by far the smallest way to store cell positions.

  • The snippet int(3fPart(3cosh( gives 1 when the input equals 3/6, 2 when it equals 4/6, and 0 when it equals 0, 1/6, 2/6, or 5/6. Saves about 6 bytes.

    0 While 1 For(X,0,93 Ans/7+49seq(pxl-Test(Y,X+1),Y,0,62 For(Y,1,61 If 2rand>isClockOn=pxl-Test(Y,X)+int(3fPart(3cosh(fPart(6ֿ¹iPart(sum(Ans,Y,Y+2 Pxl-Change(Y,X End End ClockOff End

TI-BASIC, ~105

This version is the most golfed code I have ever written, and contains some truly nasty obfuscatory optimizations:

  • I use the clock state as a flag. At the start of the program, the date/time clock is enabled, and I use the value of the global isClockOn flag to determine whether it is the first iteration. After the first frame is drawn, I turn the clock off. Saves one byte over the shortest other method and about four over the obvious method.

  • I store the states of the three columns next to the one being updated in a 63-element array of base-7 numbers. The 49's place holds the column to the right, the 7's place holds the middle column, and the units place holds the left column-- in each element, they're always 1 for a live cell and 0 for a dead cell, so an example array element may be 49+7+0=56. Then I take the remainder mod 6 of the sum of the three numbers around the cell being modified to find the total number of live neighbor cells. Saves at least 20 bytes and gives the opportunity to use the third optimization.

  • The snippet int(3fPart(3cosh( gives 1 when the input equals 3/6, 2 when it equals 4/6, and 0 when it equals 0, 1/6, 2/6, or 5/6. Saves about 6 bytes.

    0 While 1 For(X,0,93 Ans/7+49seq(pxl-Test(Y,X+1),Y,0,62 For(Y,1,61 If 2rand>isClockOn=pxl-Test(Y,X)+int(3fPart(3cosh(fPart(6ֿ¹iPart(sum(Ans,Y,Y+2 Pxl-Change(Y,X End End ClockOff End

TI-BASIC, ~105 (87 for non-competing entry)

0
While 1
For(X,0,93
Ans/7+49seq(pxl-Test(Y,X+1),Y,0,62
For(Y,1,61
If 2rand>isClockOn=pxl-Test(Y,X)+int(3fPart(3cosh(fPart(6ֿ¹iPart(sum(Ans,Y,Y+2
Pxl-Change(Y,X
End
End
ClockOff
End

This version is probably the most golfed code I have ever written, and contains some truly nasty obfuscatory optimizations:

  • I use the clock state as a flag. At the start of the program, the date/time clock is enabled, and I use the value of the global isClockOn flag to determine whether it is the first iteration. After the first frame is drawn, I turn the clock off. Saves one byte over the shortest other method and about four over the obvious method.

  • I store the states of the three columns next to the one being updated in a 63-element array of base-7 numbers. The 49's place holds the column to the right, the 7's place holds the middle column, and the units place holds the left column--1 for a live cell and 0 for a dead cell. Then I take the remainder mod 6 of the sum of the three numbers around the cell being modified to find the total number of live neighbor cells. Saves about 10 bytes by itself and gives the opportunity to use the next two optimizations. Example diagram (let's say there is a glider centered at a certain column at Y=45:

      Row # | Cell State       | Stored number | Mod 6 = cell count
      ...
      44      Live, Live, Live   49+7+1 = 57     3
      45      Dead, Dead, Live   49+0+0 = 49     1
      46      Dead, Live, Dead   0+7+0  = 7      1
      ...
    

    The center cell will stay dead, because it is surrounded by exactly five live cells.

  • After each row is completed, the numbers in the array are updated by dividing the existing numbers by 7, discarding the decimal part, and adding 49 times the values of the cells in the new column. Storing all three columns each time through would be much slower and less elegant, take at least 20 more bytes, and use three lists rather than one, because the values of cells in each row must be stored before cells are updated. This is by far the smallest way to store cell positions.

  • The snippet int(3fPart(3cosh( gives 1 when the input equals 3/6, 2 when it equals 4/6, and 0 when it equals 0, 1/6, 2/6, or 5/6. Saves about 6 bytes.

Added explanation
Source Link
lirtosiast
  • 21.5k
  • 5
  • 52
  • 127

For your TI-84 series graphing calculator (!). There is no easy way to do buffered graphics, and the graph screen has only four relevant graphics commands: Pxl-On(), Pxl-Off(), Pxl-Change(), and pxl-Test(). Uses every accessible pixel on the screen, and wraps correctly. Each cell is one pixel, and the program updates line by line horizontally to the right across the screen. Because the calculators have only a 15MHz z80 processor and BASIC is a slow interpreted language, the code only gets one frame about every five minutes.

This version is the most golfed code I have ever written., and contains some truly nasty obfuscatory optimizations:

0
While 1
For(X,0,93
Ans/7+49seq(pxl-Test(Y,X+1),Y,0,62
For(Y,1,61
If 2rand>isClockOn=pxl-Test(Y,X)+int(3fPart(3cosh(fPart(6ֿ¹iPart(sum(Ans,Y,Y+2
Pxl-Change(Y,X
End
End
ClockOff
End
  • I use the clock state as a flag. At the start of the program, the date/time clock is enabled, and I use the value of the global isClockOn flag to determine whether it is the first iteration. After the first frame is drawn, I turn the clock off. Saves one byte over the shortest other method and about four over the obvious method.

  • I store the states of the three columns next to the one being updated in a 63-element array of base-7 numbers. The 49's place holds the column to the right, the 7's place holds the middle column, and the units place holds the left column-- in each element, they're always 1 for a live cell and 0 for a dead cell, so an example array element may be 49+7+0=56. Then I take the remainder mod 6 of the sum of the three numbers around the cell being modified to find the total number of live neighbor cells. Saves at least 20 bytes and gives the opportunity to use the third optimization.

  • The snippet int(3fPart(3cosh( gives 1 when the input equals 3/6, 2 when it equals 4/6, and 0 when it equals 0, 1/6, 2/6, or 5/6. Saves about 6 bytes.

    0 While 1 For(X,0,93 Ans/7+49seq(pxl-Test(Y,X+1),Y,0,62 For(Y,1,61 If 2rand>isClockOn=pxl-Test(Y,X)+int(3fPart(3cosh(fPart(6ֿ¹iPart(sum(Ans,Y,Y+2 Pxl-Change(Y,X End End ClockOff End

Exact byte count and fulladitional explanation coming soon, but for now I will say that the snippet int(3fPart(3cosh( gives 1 when the input equals 3/6, 2 when it equals 4/6, and 0 when it equals 0, 1/6, 2/6, or 5/6.

For your TI-84 series graphing calculator (!). There is no easy way to do buffered graphics, and the graph screen has only four relevant commands: Pxl-On(), Pxl-Off(), Pxl-Change, and pxl-Test(). Uses every accessible pixel on the screen, and wraps correctly. Each cell is one pixel, and the program updates line by line horizontally to the right across the screen. Because the calculators have only a 15MHz z80 processor and BASIC is a slow interpreted language, the code only gets one frame about every five minutes.

This version is the most golfed code I have ever written.

0
While 1
For(X,0,93
Ans/7+49seq(pxl-Test(Y,X+1),Y,0,62
For(Y,1,61
If 2rand>isClockOn=pxl-Test(Y,X)+int(3fPart(3cosh(fPart(6ֿ¹iPart(sum(Ans,Y,Y+2
Pxl-Change(Y,X
End
End
ClockOff
End

Exact byte count and full explanation soon, but for now I will say that the snippet int(3fPart(3cosh( gives 1 when the input equals 3/6, 2 when it equals 4/6, and 0 when it equals 0, 1/6, 2/6, or 5/6.

For your TI-84 series graphing calculator (!). There is no easy way to do buffered graphics, and the graph screen has only four relevant graphics commands: Pxl-On(), Pxl-Off(), Pxl-Change(), and pxl-Test(). Uses every accessible pixel on the screen, and wraps correctly. Each cell is one pixel, and the program updates line by line horizontally to the right across the screen. Because the calculators have only a 15MHz z80 processor and BASIC is a slow interpreted language, the code only gets one frame about every five minutes.

This version is the most golfed code I have ever written, and contains some truly nasty obfuscatory optimizations:

  • I use the clock state as a flag. At the start of the program, the date/time clock is enabled, and I use the value of the global isClockOn flag to determine whether it is the first iteration. After the first frame is drawn, I turn the clock off. Saves one byte over the shortest other method and about four over the obvious method.

  • I store the states of the three columns next to the one being updated in a 63-element array of base-7 numbers. The 49's place holds the column to the right, the 7's place holds the middle column, and the units place holds the left column-- in each element, they're always 1 for a live cell and 0 for a dead cell, so an example array element may be 49+7+0=56. Then I take the remainder mod 6 of the sum of the three numbers around the cell being modified to find the total number of live neighbor cells. Saves at least 20 bytes and gives the opportunity to use the third optimization.

  • The snippet int(3fPart(3cosh( gives 1 when the input equals 3/6, 2 when it equals 4/6, and 0 when it equals 0, 1/6, 2/6, or 5/6. Saves about 6 bytes.

    0 While 1 For(X,0,93 Ans/7+49seq(pxl-Test(Y,X+1),Y,0,62 For(Y,1,61 If 2rand>isClockOn=pxl-Test(Y,X)+int(3fPart(3cosh(fPart(6ֿ¹iPart(sum(Ans,Y,Y+2 Pxl-Change(Y,X End End ClockOff End

Exact byte count and aditional explanation coming soon.

Added nonwrapping version
Source Link
lirtosiast
  • 21.5k
  • 5
  • 52
  • 127
Loading
Source Link
lirtosiast
  • 21.5k
  • 5
  • 52
  • 127
Loading