Chit Chat

Joined
Sep 20, 2022
Messages
302
Reaction score
41
Not much discussion happening on the forum lately.

I have no code to share, none of my programs do anything interesting.

I've been reverse engineering Devin Kilminster's prime number generator.

Its a 9 number program, written in FRACTRAN. On one level its cryptic spaghetti, on another, its a work of art.

Just my opinion.
 
Joined
Sep 20, 2022
Messages
302
Reaction score
41
If fractions are lines, and using a fraction is executing that line, then I wrote a version of a FRACTRAN interpreter that traced for each line, which lines came next.

The output is not the full picture, but allowed me to make a diagram, similar to a state transition diagram.

The diagram gave me a feel for what was happening, and what each register means. It also clarified that it was using exactly the same algorithm as Conway's except the test factor was starting at 2 and increasing.

From here I wrote a little pseudocode and comments for each line. Only 4 GOTOs, so there wasn't much spaghetti.

It did use an interesting trick for controlling the jumps, much better than Conway's state flags, which I will steal.
 
Joined
Sep 20, 2022
Messages
302
Reaction score
41
I've just had a look at Conway's paper. I should have read this first, but I just assumed it would be way over my head and that all the salient details were in the book/article that I was reading.

His flowcharts are much better than my diagrams. Using different arrowheads for precedence is a good idea.
 
Joined
Sep 20, 2022
Messages
302
Reaction score
41
It is a good chat program.

I ask it 3 types of questions: things I want to know, and can verify; things I already know, to test ChatGPT itself; nonsense, just to have a bit of fun.

I think its 90% google search and 10% Eliza.

The last thing I asked it about, it got a bit wrong. I didn't want to give it any feedback because then the next person to ask the same question might get a slightly better answer, giving the impression that ChatGPT is better than it really is.
 
Joined
Sep 20, 2022
Messages
302
Reaction score
41
I wrote a 56 fraction program to calculate the integer square root of a number, using Hero's method.

Not my best work, but my goal was to create subroutines.

The argument passing and return value are implemented similar to using global variables in BASIC.

Its already a nightmare to debug, what I need now is a stack, to pass arguments and have local variables.

Not sure yet how to do that.
 
Joined
Sep 20, 2022
Messages
302
Reaction score
41
A register could hold a stack, using a predefined BASE. Pushing X would be multiplying by BASE and adding X. Popping into X would be dividing by BASE, putting the remainder into X.

The only downside is there is no random access, so I can't use a stack for local variables.

That's a 8086 assembly idea, to have more variables than registers, and not the only way to skin this rabbit.

FRACTRAN has no register limit, so my subroutines could push any registers, use them, then restore (pop) them before returning.

This is going to run like a slug, but should work.
 
Joined
Sep 20, 2022
Messages
302
Reaction score
41
The stacks worked, I needed two, because I have no random access.

1: general purpose and return lines
2: arguments and return values

If the square root program is written in the structured programming style, it won't finish running in my life time. If I push more than 3 values, I'm in a world of pain.

Since I only have 2 subroutines, which don't nest, and are only called from one location, I can use jumps.

When a program is running, I print the registers using roman numerals. It looks like a physical machine is operating. Very eye pleasing.

I wrote a preprocessor to allow me to use macros, because a person would have to be nuts to write directly in FRACTRAN.
 
Joined
Sep 20, 2022
Messages
302
Reaction score
41
I coded a NAND function. Since all logical functions can be made from nand gates, I stopped there.

Making a Quine program is a bit tricky, I have a design but it is completely un runnable, due to the large numbers it needs.

I'm only 90% sure the pseudocode is correct.

I view a program as a string, made of digits 0 to 9, slashes, and commas. I convert that into an integer, which assumes the string is a base 12 number. I call this number y.

The quine, when given an input of 3, outputs 5^y.

I'm bending the rules a bit, an ideal quine would output y.
 
Last edited:
Joined
Sep 20, 2022
Messages
302
Reaction score
41
When I do a Googoo search for example programs, I can find 3 references to FRACTRAN programs that interpret FRACTRAN programs.

This kind of program is fascinating.

The one I read was mighty long, which is strange because I'm 99% sure Conway's POLYGAME is an interpreter, and is tiny.

I'm in the process of wrapping my head around POLYGAME. Its tricky because I can't do a test run, due to the size of the numbers.
 
Joined
Sep 20, 2022
Messages
302
Reaction score
41
The catalogue number 2268945 = 3^3 * 5 * 7^5 confused me for a while.

I thought all that 2^(2^n) at the start of the paper was a typo because it wasn't consistent with the end of the paper 2^N.

It looks like he's jumping midway into his POLYGAME flowchart, using register 7 and starting in state 1.

Personally, I'd start at state 23, with a c value of 3^8 * 5^12 * 23, which does the same thing.

As far as testing POLYGAME, the best I can do is test his flowchart's branches with trivial values of M.

Goes against my grain, I don't feel a program is complete without running multiple test cases.
 
Joined
Sep 20, 2022
Messages
302
Reaction score
41
Here's my POLYGAME input that interprets a program that does nothing but increment register 3.

2^(3^x) * 3^72 * 5^80 * 17^1 * 23

output: 2^(3^(x+1))

I have officially hit the bottom of this rabbit hole.

While falling, I did come across an idea called the WDR paper computer, an assembly style language with 5 instructions, interesting...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,431
Messages
2,571,678
Members
48,796
Latest member
Greg L.

Latest Threads

Top