12
\$\begingroup\$

There has been some debate about whether or not using Self-Modifying Brainfuck counts as a "cheating quine":

Write a Metaquine

Golf you a quine for great good!

About SMBF:

  • The program's source code is located on the tape, to the left of the intial tape pointer position
  • Modifying the program's source code at runtime results in the behavior of the program being changed - the code on the tape is the actual code being executed, not just a static copy of the original source code

Should SMBF's ability to read/modify its own source code be considered "cheating" for quining purposes?

\$\endgroup\$
  • \$\begingroup\$ Interesting question. If using SMBF’s capabilities of self-modification is cheating, then I assume that my beeswax quine is a cheating quine as well: codegolf.stackexchange.com/a/67994/39407 \$\endgroup\$ – M L Feb 22 '16 at 19:57
  • \$\begingroup\$ @ML Yes, I would say that is a cheating quine. \$\endgroup\$ – Mego Feb 22 '16 at 20:00
15
\$\begingroup\$

Yes, reading the source code in SMBF is "cheating" in quining

For our purposes, a cheating quine is defined as a quine program that utilizes the direct or indirect reading of its source code (such as opening and reading the file the source code is stored in, a built-in function that returns a string containing the program's source code, etc.). The ability to modify the program's instructions at runtime in SMBF does not change the fact that it reads its own source code, and therefore quines in SMBF that utilize this behavior are cheating quines.

\$\endgroup\$
  • \$\begingroup\$ What about accessing initialized memory, as a ZISC would do? \$\endgroup\$ – Esolanging Fruit May 23 '17 at 4:08
  • \$\begingroup\$ @Challenger5 That isn't relevant to this question. \$\endgroup\$ – Mego May 23 '17 at 4:09
  • \$\begingroup\$ It's a generalization of the question. You could see SMBF as a ZISC. \$\endgroup\$ – Esolanging Fruit May 23 '17 at 4:10
  • \$\begingroup\$ How does this interact with stringification? \$\endgroup\$ – user77406 Feb 11 at 22:30
  • \$\begingroup\$ @Rogem I would argue that stringification is just a built-in function that returns a stringing containing part of the program's source code, and thus is cheating for writing quines. I'm interested in others' viewpoints, though. \$\endgroup\$ – Mego Feb 12 at 1:24
  • \$\begingroup\$ Personally of the same opinion, but it seems like it's extremely popular for quines here... \$\endgroup\$ – user77406 Feb 12 at 5:20
9
\$\begingroup\$

Yes it's cheating, but let's elaborate

An argument commonly given to defend SMBF, but abstracted: If function q printed the source code, then yes, it's a cheating quine. If function q' accessed a copy of the source code, is it still a cheating quine? Well, yeah, probably. SMBF has a way to emulate said q' function, but with a twist: it accesses a writable copy of the source code; once this copy is modified, it is no longer the source code, rather, something similar to it. Then how could it possibly be said of SMBF that it's reading it's own source code?

buzzer sound That's just wrong. Let's give a counter argument with the same logic:

It's the night before the day of the big Shakespeare test. You get to bring in a notecard that gives some facts, but you are not allowed to quote any of the plays directly. Well... you think to yourself, If I put a near copy of a quote, it's not the same quote, so it's okay! You proceed to do this and get a 0 on the test for cheating. russian accent No big surprise.


Here's an argument given here:

[In response to a complaint about SMBF] No, it's not. The tape that the commands modify is the same tape that it operates on. That's part of the specification of the language. It's not just reading a separate copy of its source, and it's not opening its own file. It's looking at its own source dynamically on the same tape, with the power to execute and modify it mid-execution.

First, it is stated that The tape that the comands modify is the same tape that it operates on. Well, what if my language has it's source code on the stack, with the capacity to modify that string? This is to the same effect, but in a much more absurd setting. Here, it's plainly obvious that it's cheating. Not to mention that it is also not two sentences later "It's looking at it's own source..."

\$\endgroup\$
  • 1
    \$\begingroup\$ Then what if I just copy the BF quine in SMBF? The code source is still accessible so is that cheating, too, even if it's not used? What if only part of the source is used, or it's modified first? \$\endgroup\$ – mbomb007 Mar 18 '16 at 21:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .