TSC Quines

Jan 6, 2013 at 6:21 PM
Not anymore
"Run, rabbit run. Dig that hole, forget the sun."
Join Date: Jan 28, 2010
Location: Internet
Posts: 1369
Age: 34
http://www.madore.org/~david/computers/quine.html

It is possible to write a quine in any programming language that is Turing complete.
Some of you don't believe that TSC is Turing complete. It is.

A quine is a program that prints its own source code, without using File I/O or other cheating methods.
Try to write a quine in TSC. It should print to the Cave Story message box.
I will also try to write one using my knowledge of computer science and programming.

If you can do it faster than I can... in other words, post a working non-cheating TSC Quine before I am able to,
then you can ask me for a certain type of favor and I will probably do it for you
unless it's 100% unreasonable. You could ask me to make you a small Cave Story mod, or you could ask me
to wear a long hair wig and wedding dress in public and take photos while trying to fool people. Anything goes.
When writing the quine, avoid hacking the TSC language with x86 Assembly.
Note: Asking me to make you a fully completed Cave Story mod is an example of an unreasonable request.
 
Jan 6, 2013 at 9:24 PM
In my body, in my head
Forum Moderator
"Life begins and ends with Nu."
Join Date: Aug 28, 2009
Location: The Purple Zone
Posts: 5998
Jan 6, 2013 at 9:36 PM
The Preacher
"Wacka-Wacka-Wacka-Wacka-Wacka-Wacka-Wacka-Wacka-BLEIUP"
Join Date: Feb 20, 2011
Location: lost in translation
Posts: 336
Age: 31

How does something qualify for "cheating"? What can or can't I do with my file?

Am I allowed to use a blank script?

I can edit the font in order to make the special character "circle" become a "<", or I can hack TSC in order to allow the use of "<" in messages under certain conditions, or something like that, and it would be somewhat easy.

I could also not use the message box and instead write with blocks, which demands so much work I won't even try.

Another very complicated way (that has a good chance of not even existing) might be to cheat the system by using weird combinations of characters in the script so that the game doesn't understand what's going on and prints a "<" somehow, but that would be like coding in Malbolge.

Otherwise it's simply not possible since we can't use "<" in message boxes.

Or did I miss something?



EDIT: Oh I see Noxid used the "blank script" method without asking.
 
Jan 6, 2013 at 9:40 PM
Not anymore
"Run, rabbit run. Dig that hole, forget the sun."
Join Date: Jan 28, 2010
Location: Internet
Posts: 1369
Age: 34

Congrats Noxid! Assuming that your TSC file can be encrypted and run, you have successfully written a quine using Pixel's scripting language.

It is perfectly possible to print a < to the screen without assembly hacking.
YOU CANNOT CHANGE THE FONT OF THE GAME.
YOU CANNOT MODIFY THE EXECUTABLE.

Hint: Use out-of-bounds flags to modify the RAM offsets of the game, and then figure out how to trick the executable to run arbitrary code inside the flagdata and RAM by loading an illegal Profile.dat save file.

Hint 2: Self modifying code might be useful. The current position of a TSC script is kept in RAM, and the contents of the current TSC file should also be in memory somewhere. Remember that you can modify memory using flags. First figure out how to jump to a specified address inside the executable, and go from there.

You will need to write a logic system, or maybe even a 32-bit x86 virtual machine, using only <FL+, <FL-, and <FLJ to trigger individual circuits and logic gates inside your machine. This x86 virtual machine must be written in pure, non-hacked TSC.

I never said making a TSC quine longer than 0 bytes would be easy.

Basically, I am telling you to do assembly hacking without changing a single binary bit inside the executable.

You have to run x86 assembly code, and you only have TSC.

The only way to solve this is to write an x86 architecture emulator by USING PIXEL'S ORIGINAL VERSION OF TSC. :awesomeface:
 
Jan 6, 2013 at 10:02 PM
In my body, in my head
Forum Moderator
"Life begins and ends with Nu."
Join Date: Aug 28, 2009
Location: The Purple Zone
Posts: 5998
Carrotlord said:
by loading an illegal Profile.dat save file.
is that not against the rules
 
Jan 6, 2013 at 11:05 PM
Not anymore
"Run, rabbit run. Dig that hole, forget the sun."
Join Date: Jan 28, 2010
Location: Internet
Posts: 1369
Age: 34
You have to print the hexadecimal contents of the Profile.dat you use if (and only if) you use an unusually constructed Profile.dat file.
 
Jan 7, 2013 at 1:25 AM
Senior Member
"This is the greatest handgun ever made! You have to ask yourself, do I feel lucky?"
Join Date: Jun 12, 2011
Location: 0x00000000 0xC00E0FF0 0xFFFFEFD4 0xC0000000
Posts: 108
Carrotlord said:
Note: Asking me to make you a fully completed Cave Story mod is an example of an unreasonable request.
I was thinking, maybe like trying to write a TSC that will produce more TSC code that will produce more TSC code, etc.

Sort of like a Mandelbrot fractal codified.
 
Jan 7, 2013 at 6:26 AM
Not anymore
"Run, rabbit run. Dig that hole, forget the sun."
Join Date: Jan 28, 2010
Location: Internet
Posts: 1369
Age: 34

I figured out like three ways to do this sort-of successfully.



1. Use <MNA to show the map name. The map name should contain the contents of the TSC file. You should be able to replace the line break after an event number with any two characters in order to make the entire TSC file one line long.



2. Roll the credits. You can use < in the credits and even check for flags.



3. Use tiles to print "characters" onto the map. Now < is not an obstacle!

EDIT: Since I have given away the solution, nobody can ask me what to do, except Noxid, who posted the first working TSC quine.

EDIT2: Okay then. Now I most likely have to trick GIR's sister into pretending to seduce GIR and then laughing at him. Man, that's gonna be difficult.
 
Jan 7, 2013 at 6:59 PM
The Preacher
"Wacka-Wacka-Wacka-Wacka-Wacka-Wacka-Wacka-Wacka-BLEIUP"
Join Date: Feb 20, 2011
Location: lost in translation
Posts: 336
Age: 31
Carrotlord said:
3. Use tiles to print "characters" onto the map. Now < is not an obstacle!
Hiino said:
I could also not use the message box and instead write with blocks, which demands so much work I won't even try.
Also, credits and <MNA can't be changed by the TSC scripts so it's like using premade external resources so it breaks one of the fundamental rules of Quines. So is editing Profile.dat.
 
Jan 8, 2013 at 12:25 AM
Administrator
Forum Administrator
"Life begins and ends with Nu."
Join Date: Jul 15, 2007
Location: Australia
Posts: 6210
Age: 38
Carrotlord said:
1. Use <MNA to show the map name. The map name should contain the contents of the TSC file. You should be able to replace the line break after an event number with any two characters in order to make the entire TSC file one line long.
Doesn't that count as modifying the interpreter? Map names are stored within the executable.
 
Jan 8, 2013 at 12:52 AM
Not anymore
"Run, rabbit run. Dig that hole, forget the sun."
Join Date: Jan 28, 2010
Location: Internet
Posts: 1369
Age: 34
Map names are stored in th executable, so it's kinda cheating. But mainly I meant not directly modifying any of the x86 that could possibly be executed as code.

When you said "blocks", I thought you meant blocks of code, as in tokens delimited by curly braces. I had no idea what you were trying to do.

Credits are a variant of TSC. The Credits TSC is a poorly documented and much more advanced version of TSC that Pixel decided to make just for the heck of it. It should have a completely different parser, but can still interact with flags and display text and pictures to the screen.
 
Jan 8, 2013 at 12:31 PM
Administrator
Forum Administrator
"Life begins and ends with Nu."
Join Date: Jul 15, 2007
Location: Australia
Posts: 6210
Age: 38
But you can only run the credits from another TSC file. What about the contents of that file?
 
Jan 8, 2013 at 1:38 PM
Not anymore
"Run, rabbit run. Dig that hole, forget the sun."
Join Date: Jan 28, 2010
Location: Internet
Posts: 1369
Age: 34
You have to print the TSC code of that file too.

If you have two Python modules alpha.py and beta.py, and you run your quine in alpha.py and decide to import beta.py,
you would need to print the contents of beta.py too for the quine to be successful.
 
Top