Control Block

## Purpose

This block is the hub for all overworld circuit-related activities. Place it in the world, and right-click, and it'll display a GUI with every circuit in the mod! From here, you can read circuit descriptions, test circuits, craft circuits, and even create custom downsized circuits from real redstone circuits!

## Crafting

A control block may be crafted out of five diamonds and four smooth stone blocks.

## Elementary Usage

The front page of the Control Block GUI will display a scrollable list of all installed circuits on the server, along with their icons.

Clicking any of the entries will bring up the circuit's description page. The description of a circuit will contain information about a circuit's behavior and configuration options.

If the circuit is unlocked (by default or through a successful test), the circuit's cost will appear in the titlebar, and the "Craft" option will become available in the bottom-left corner. Otherwise, only the "Test" option will be available.

## Crafting Circuits

Clicking the "Craft" option will bring up a new page where the player can set the *Crafting Cell* for the Control Block. The *Crafting Cell* for a Control Block is the {Circuit, Configuration Options} pair that will be used to craft new circuits from the Control Block. The current crafting cell will remain set unless it's unset by another crafting action.

The costs for a circuit are displayed prominently on the crafting page. Once the player has set the ordered config option list to a valid configuration (updates instantly), the crafting cell will be set, and the player may craft circuits by dragging item stacks into the slots beneath "Craft".

## Testing Circuits

### Testing Frame

In order to test your own redstone circuit against its implementation, you must first build a valid *testing frame*. A *testing frame* is a multi-block structure built out of Frame Blocks in the shape of the outline of a rectangular prism, with a Control Block on one of its corners. Tests within the frame may be initiated from the corner Control Block. All valid *testing frames* are at least 3x3x3 in size, and the bigger the better -- all circuits under test must fit entirely within the testing frame!

### Configuring a Test

Once the "Test" button has been clicked from a circuit's description page, a test configuration page will pop up. On this page, you may enter the configuration options for the version of the circuit you'd like to test and configure available parameters for the test itself.

The "Delay" option is most common on combinational circuits. It allows you to enter the propagation delay for signals through your circuit, so the tester can adapt its testing frequency appropriately. The higher the value, the longer the time between test cases, which will slow the testing process.

### Testing Process

After the "Test" button has been pressed from the test's configuration page, the control block will search within the testing frame for *Input* and *Output* circuit blocks to associate with the circuit-under-test's inputs and outputs. These blocks are indexed according to the order of arguments to the circuit under test (see Argument Mapping).

Once the input/output blocks have been found, the sides of the testing frame are filled in with *Unbreakium*, an unbreakable transparent block. The frame itself also becomes unbreakable, and all blocks one block below the "floor level" of the testing frame are replaced with Unbreakium.

If any living entity is detected within the testing frame during a test, the test will instantly fail.

During the test, the input blocks emit signals to the circuit under test in a timed sequence. The output is read by the output blocks, which is tested against either a set of (exhaustive/random) auto-generated test cases (for combinational circuits), or against some testing code (written using the API).

If the test fails, a message will pop up displaying the failed test inputs.

### Result of Successful Tests

If the test passes, the Control Block will search through the testing frame to determine the cost of the newly-unlocked circuit. This cost is determined by summing the *base crafting costs* of all blocks within the frame, and then passing it to a *cost computation function* (default: log). The function used is configurable in the mod's config file.

*Base crafting costs* are determined by finding the "most basic" crafting items used to craft a particular block. For example, a redstone repeater has stone blocks, redstone, and wood planks as items in its base crafting cost. The base crafting cost of a circuit is defined as the cost of the circuit *before* passing it to the cost computation function. This ensures that player can't get cheaper and cheaper crafting recipes just by putting the same circuit through a tester over and over again -- the fundamentals of the constructed redstone circuit often must change to obtain more efficient crafting recipes! This also means that even from the most basic circuits and the most generous cost functions, every block counts.

## Custom Circuits

**NOTE:** To use this feature, the server administrator must have the JDK installed!

**NOTE:** This feature currently only works with combinational circuits with a relatively-small number of inputs (see Configs for how to configure the maximum) -- more would require writing a "Minecraft to Java" compiler!

From the main page of the control GUI, there is a folder titled "custom/". Clicking it will yield a listing of subdirectories named after players who have constructed custom circuits, together with a "Make" button in the bottom right-hand corner.

Clicking the "Make" button will take you to a page where you can name your circuit and configure the delay between circuit input test cases. Upon clicking the "Rec" button, the Control Tile entity will record (in a process similar to testing) the responses of the circuit in the testing frame to all possible inputs.

Once this is done, a page will pop up displaying the recorded input/output cases for the circuit. Check to make sure everything looks okay, then hit "Next", otherwise hit "Back" to rename or set up a test with new configs.

Then, write a circuit description. Try to match the style of the mod-default circuit descriptions, and write it as if a complete newbie is trying to build the circuit.

Finally, create an 16x16 icon for the circuit using the icon editor, and hit "Done"

All of the user-entered info will be sent to the server and a Java .class file will be created for the circuit implementation. If this process completed successfully, you'll be sent back to the list of circuits, but with a new entry!

 Once you've done all that, you still will need to test the newly-created circuit to be able to craft it.