1
0

Added Markdown description for BefunGen/BefunRep

This commit is contained in:
Mike Schwörer 2014-12-08 11:31:34 +01:00
parent 5bd4ce2185
commit 9ee572fa9f
3 changed files with 96 additions and 1 deletions

View File

@ -0,0 +1,52 @@
BefunRep is an command line tool to calculate Befunge93 number representations
![BEFUNREP_MAINWINDOW](/data/programs/desc/BefunGen/01_Manuals/BefunRep_Main.png)
To execute BefunRep you need to open the windows command line (cmd.exe).
The representations are saved in a "safe", you can give the safe-path with the parameter **safe**.
There are three safe-formats available: binary (.bin), CSV (.csv) and JSON (.json). But for most cases the binary safe is the best, especially for bigger safes.
When you first generate a safe you have to give him a number range with the parameters **lower** and **upper**
> **\> BefunRep -safe="binsafe.bin" -lower=0 -upper=1000 -reset**
The **reset** command resets the safe if the file already exists.
You can update an existing safe and search for improvements
> **\> BefunRep -safe="binsafe.bin"**
Here the existing limits in the safe are re-used. But you can also extend a safe and give him a new range.
> **\> BefunRep -safe="binsafe.bin" -lower=-100 -upper=3500**
As you can see with every iteration on the same range there is a chance to find a few improvements.
You can also specify a fixed amount of iterations with the parameter **iterations**. A negative iteration number will result in calculations until no more improvements can be found.
> **\> BefunRep -safe="binsafe.bin" -reset -lower=-100 -upper=3500 -iterations=-1**
When you calculate a new safe you will get a lot of console output, this will probably slow your program down. The parameter **quiet** (or just **q**) prevents the "Found improvement" output.
Also you can specify a statistics level from 0 to 3 with **stats**, this regulates the safe statistics you can see at the end of the program.
> **\> BefunRep -safe="binsafe.bin" -reset -lower=-100 -upper=3500 -iterations=-1 -q -stats=3**
If you already have an safe and don't want to calculate anything so you only see its statistics you can use iterations=0
> **\> BefunRep -safe="binsafe.bin" -iterations=0 -stats=3**
The binary safe format is not really human readable, to get the results in a better format use the **out** parameter. Supported formats are CSV (.csv), JSON (.json) and XML (.xml). XML and JSON are useful to redirect it to other programs and CSV to manually read them, because CSV doesn't need to escape any characters.
> **\> BefunRep -safe="binsafe.bin" -reset -lower=-100 -upper=3500 -iterations=-1 -q -out="csvoutput.csv"**
Similiar to the statistics you can also use the iterations=0 trick to generate an output of an existing safe
> **\> BefunRep -safe="binsafe.bin" -iterations=0 -out="csvoutput.csv"**
Internally BefunRep has multiple algorithms that are executed one after the other. Normally all are executed but you can also specify a single one to use with the parameter **algorithm**
> **\> BefunRep -safe="binsafe.bin" -reset -lower=-100 -upper=3500 -algorithm=3**
If you need a list of the possible arguments execute BefunRep without any arguments or with **help**
> **\> BefunRep -help**

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

View File

@ -1,12 +1,15 @@
*BefunGen, a Befunge-93 code generator from a procedural C-like language*
**(Over time this has more become my collection of various Befunge tools. Many of them are quite useful alone but still, most are centered around BefunGen.)**
> **NOTE:**
>
> BefunGen is a collection of multiple programs:
>
> - **BefunGen**: A TextFunge to Befunge-93 compiler
> - **BefunExec**: A fast Befunge-93 interpreter
> - **BefunHighlight**: A intelligent Befunge-93 syntax-highlighter
> - **BefunWrite**: An IDE for TextFunge
> - **BefunRep**: An commandline tool to calculate number representations in Befunge
 
@ -84,3 +87,43 @@ BefunHighlight tries to solve this by evaluating every possible path an program
Based on these informations it's now possible for another program to better highlight the source code.
Be aware that **p**ut and **g**et operations will invalidate the calculated values and it is needed to update them.
## BefunRep
A common problem with Befunge is the *(efficient)* representation of big numbers. *(= putting a number on the stack with the least amount of instructions)*
BefunRep is a commandline tool to generate a list of representations for all numbers in a specified range. I'm pretty sure the calculation of the optimal representation is a NP complete. But BefunRep tries to to find good representations for all numbers via various algorithms. And it does a pretty good job. It finds for all the numbers between -1 million and +1 million representations with a maximum of eleven characters.
Here an example call to BefunRep:
> **\> BefunRep.exe -lower=0 -upper=1000 -iterations=3 -stats=3 -q -safe="safe.bin" -out="out.csv" -reset**
This calculates the numbers from **0** to **1000**.
With a maximum of **3** iterations *(use -1 to calculate until no more improvmenets can be found)*
Safe the results in binary format in the file **safe.bin**
If the safe already exists it will be reseted (-**reset**)
And exports the results readable to **out.csv**
You can also update an existing safe
> **\> BefunRep.exe -safe="safe.bin" -iterations=-1**
Or don't calculate anything and only output an existing safe into another format
> **\> BefunRep.exe -safe="safe.bin" -iterations=0 -stats=3 -out="out.json"**
Here an example of a few calculated values:
Number | Representation
-------|----------------
113564 | `"tY!"**3/`
113565 | `"qC-"**3/`
113566 | `"[' "**2-`
113567 | `"[' "**1-`
113568 | `"[' "**`
113569 | `"~~U"++:*`
113570 | `"[' "**2+`
113571 | `"wj"*5+9*`
113572 | `"[' "**4+`
113573 | `"[' "**5+`
113574 | `"E~(&"*+*`