This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
TangentDelta's profile picture

[1.4.6]AutomaPaint 1.1.1 (Turn computers into integrated circuits!))

Started by TangentDelta, 15 October 2012 - 06:18 PM
TangentDelta #1
Posted 15 October 2012 - 08:18 PM


Welcome to AutomaPaint! A 2D cellular automaton lab, the first ever for ComputerCraft!

Created as a spiritual successor to TangentAutomaton (a one-dimensional cellular automaton lab), AutomaPaint offers many of the same features as its predecessor! A custom starting generation, custom rules, and a re-sizable environment!

FEATURES
Spoiler
  • Paint Mode
Spoiler

A.K.A: "The Canvas". A pretty generic paint program, paint mode offers an environment where users can set the starting generation for their automaton. Pixel placing is done with the left mouse button, pixel erasing is done with the right mouse button, and pixel color picking is one with the middle mouse button. using the scroll wheel scrolls through all the colors, indicated at the bottom of the screen.

To bring up the main editor menu, press the "ctrl" key. On the bottom of the editor, five buttons, "[L] [M] [T] [X]", will appear. "[L]", "Load", does what you'd expect it to do, it loads a TangentPaint file. Clicking on it will bring up a prompt on the bottom, where you enter the name of your file. Make sure the file is in the same director as TangentPaint, or else nothing will get loaded. "", "Save", is also what you'd expect, it saves all data from the text editor and paint mode "canvas" into a save file. Clicking on it brings up a prompt that you can type in the name of your file. "[M]", "Menu" brings up a menu with a few buttons: "[TXT] [BACK] [START]". "[TXT]", will take you to the text editor. "[BACK]", will take you back to the canvas. "[START]", will take you to the cellular automaton environment.

The "[T]" button, "tools", will bring up a menu containing editing tools. Currently, the only tool in there is the "line tool". To use the line tool, have the color you want to use already selected, and click on the starting point. A "1" with a background of the color you chose previously will appear in the spot. The second place that you click on will draw a line from the "1" point, to the place you clicked. WARNING: Panning while using the line tool has unpredictable results! You have been warned!

The last button, "[X]", simply stops the script, and takes you back to the terminal.

Using the arrow keys in the canvas pans you around. Panning into a place with nothing expands the canvas. Keep that in mind!
  • Text Editor Mode
Spoiler
Text editor mode is a rather simplistic text editor, designed to do nothing more than edit the rules for the automatons. To leave this mode, and return to the canvas, press the "Ctrl" key. All changes you make here are automatically saved when you quit. Please take note that any "spaces" in the editor act as a "carriage return", and anything past one will not get saved! Remember, I made this editor for editing a simple CA rule system, not writing pretty attachment notes on images!
  • Cellular Automaton Lab
Spoiler
The star of the show, the CA lab allows you to run the CA that you create in the other two editors. The environment is finite, so any gliders that hit the side of the world will act as if they hit a brick wall, and stop. Future version might allow you to run this mode on a monitor.

The new interface for the CA Lab can be brought up with the "Ctrl" key. On this menu, you'll see four buttons: "[#] [BACK] [BACK & SAVE] [START GENERATING]". "[#]" will bring up a (currently a bit buggy) menu that allows you to enter how many generations you want the CA to run. "[BACK]" will take you back to the canvas. "[BACK AND SAVE]" will bring up a prompt asking if you're sure you want to overwrite the canvas with the sandbox. If you hit the "Y" key on your keyboard, the canvas will be over-written with the current generation in the CA. Hitting anything else will close it, and take you back to the CA Lab. "[START GENERATING]/[STOP GENERATING]" Either turns the automatic clock on, or off. The CA will run as fast as it can with this on.

THE RULE SYSTEM
SpoilerThe rule system for the CA lab was made to be as small and efficient as possible. If you have any questions on 2D CA rules, make sure to check out the page on wikipedia.

The syntax for the rule system is as follows:
A>B|X-Y,
A is the state to turn from if the conditions are met. B is the state to turn to if the conditions are met. Basically think of the ">" as an arrow. "A turns into B". "|" means "If the following condition occurs". "|" can be replaced with ":", which means "If the following condition does not occur". This is useful for rules where cells die if they're not surrounded. X is the number of cells in the states defined in Y that are required to trigger the A>B. "," is simply there as a placeholder for future symbols. If you don't include the "," at the end, the rule won't work! I'm going to change this in the next version!
Examples:

Conway's game of life:

0>1|3-1,
1>0:23-1,
A cell with a state of 0 will become a cell with a state of 1 if it is surrounded by 3 neighbors with the state of 1. End.
A cell with a state of 1 will become a cell with a state of 0 if it is not surrounded by 2 or 3 neighbors with the state of 1. End.

WireWorld:

1>2|0-F,
2>3|0-F,
3>3|0-F,
3>2|12-1,

New in version 1.1.1:
To use the redstone output system, have the resulting state be a "@". Depending on what side of the cell that is reciving contact, a redstone signal will be emitted. An example use of this symbol, for use in wireworld, is "4>@|1234-1". The "turn from" value is simply the state that the "sensor" will use when placed down. It will emit a redstone signal if it is surrounded by 1, 2, 3, or 4 cells with the state of 1.

The side of the computer that the redsotne will be emitted from is dependent on what side of the cell was "collided" with. Contact with the bottom of the cell will output a redstone signal on the bottom of the computer, contact with the right side of the cell with output the the right side of the computer, etc.

Sensing of what side the cell was "interacted" with is the first step towards the JvN neighborhood, which should be implemented within the next 5 versions.

CHANGE LOG
Spoiler–V. 1.0.1:
–Cleaned up the code a bit
–Updated the os.pullEvent system to the new version in Pre. 3
–Going into the CA lab now saves, and ten loads, to a local file. This helps with keeping the rule system cleaned.

–V. 1.0.5
–Cleaned up the code a bit more
–Added panning and scrolling!
–Added a better rendering system.
–Changed the save system a bit. OLD SAVES WILL NEED MODIFYING!
–Fixed a few random rendering bugs in the CA lab
–CA lab should run a bit faster

–V. 1.0.9
–Added a line tool! Woot!
–Canvas now has a "character" layer and a "color" layer, making it 3D.
–Renovated the rendering code to support the new 3D canvas
–Ctrl now hides/shows the toolbar. A bit buggy, but it works for now.
–Cleaned up some troublesome code
–Added a toolbar to the CA lab
–Allowed saving changes from the lab, to the canvas.
–WARNING: Some parts of the line tool are quite buggy, as it is still a WIP! Use at own risk!

–V. 1.1
–Cleaned up the code a bit.
–Created a new menu system.
–Added redstone output!
–Changed the ">" symbol to "}".
–Changed the "-" symbol to "/".
–fixed the weird jumpy CA Lab issue

–V. 1.1.1
– !Completely re-wrote the rules system, speeding things up greatly
– !Fixed a bug with the "back" menu.
– +Added back ">" and "-"
– +New redstone output system ("@"). Now dynamic, and much less cumbersome!
– +Added some groundwork for JvN neighborhood*
– +Added "Known bugs" section to changelog
– +Added "Next version" section to changelog
– +Added "Planned" section to changelog
– -Removed some testing code
– -Removed easter eggs

KNOWN BUGS
Spoiler– !!Text editor will have artifacts from previous rule that was loaded
– !Minor flickering in some places
– !!Line tool glitches out if you pan the canvas while using it
– !!Clicking on load, then pressing "return" with nothing entered does weird stuff

NEXT VERSION
Spoiler– Rectangle tool
– Better text editor
– Attempt to remove annoying "," character at end of rules

PLANNED FEATURES
Spoiler–JvN neighborhood
–Support for more than 16 cell states
–Redstone input
–Color selection menu
–"Will always" symbol for rule system
–"Wildcard" symbol for rule system
–More tools in tool menu
–Better save system
–Scrolling in rule editor

Download should be at the bottom of this post. Install it just like any other computercraft script! I apologize for the messy code. As development continues, so will the code's neatness. Messy code is a sign of development!

Please report all bugs in this topic!

Download: https://dl.dropbox.c...42/TangentPaint
Cruor #2
Posted 15 October 2012 - 08:19 PM
Finaly you got it working and posted it :D/>/> nice work TD, will look at it later and gives them feedbackz!
TangentDelta #3
Posted 15 October 2012 - 10:03 PM
Sorry for the rather rushed/sloppy job on this post, I wasn't paying attention to time and had to quickly leave!
Noodle #4
Posted 15 October 2012 - 10:22 PM
Cool!
TangentDelta #5
Posted 16 October 2012 - 09:50 PM
Development is progressing in leaps and bounds! The next version will hopefully add support for massive rules, like the JvN rule, which has a whopping 30 different states!

All old saves won't work with the current 1.0.5 version. To make them compatible, open them up, and where it has the width and height, put a "|" after that number, followed by the same exact number. Sorry for this inconvenience!
TangentDelta #6
Posted 18 October 2012 - 01:05 AM
I think my program is the first one to include a "line" tool! The math in that thing is insane!
billysback #7
Posted 18 October 2012 - 07:55 AM
I created a line function for MCTC :P/>/>, not to boast or anything… (I also created a circle, polygon and rectangle function…)
Spoiler

function drawLine(x1, y1, x2, y2, tag)
		local xdif = x1-x2
		local ydif = y1-y2
		local grad = ydif/xdif
		local curpos = 0
		for i=1,ydif,1 do
				if grad <= 1 then
						setPixel(x1+curpos, i)
				else
						for j=1,tonumber(grad),1 do
								setPixel(x1+curpos+j, i)
						end
				end
				curpos = curpos + grad
		end
end

function drawLine(pos1, pos2, tag)
		drawLine(pos1[0], pos1[1], pos2[0], pos2[1], tag)
end

function drawSquare(corner1, corner2, corner3, corner4, tag)
		drawLine(corner1, corner2, tag)
		drawLine(corner2, corner3, tag)
		drawLine(corner3, corner4, tag)
		drawline(corner4, corner1, tag)
end

function drawCircle(center, radius, tag, fill)
		-- (x-a)^2 + (y-:)/>/>^2 = r^2 (formula, where r is radius, x and y are coordinates and a and b is center)
		local rads = radius^2
		local topright = {center[0]-radius, center[1]-radius}
		local bottomleft = {center[0]+radius, center[1]+radius}
		for cx=topright[0],bottomleft[0],1 do
				for cy=topright[1],bottomleft[1],1 do
						local xb = (cx-center[0])^2
						local yb = (cy-center[1])^2
						if (xb+yb) == rads then
								setPixel(cx, cy, tag)
						elseif fill and (xb+yb) <= rads then
								setPixel(cx,  cy, tag)
						end
				end
		end
end

function drawPolygon(points, tag)
		for i,v in ipairs(points) do
				local precorner = nil
				if i == 1 then
						precorner = points[#points]
				else
						precorner = points[i-1]
				end
				drawLine(v, precorner, tag)
		end
end
use them if you want, obviously you will have to change "setPixel" in the draw line function and draw circle function to whatever your set pixel color function is :)/>/>

Could you create an example GIF/video of this in action? It would probably increase interest after they see what and how the lab part works.
TangentDelta #8
Posted 18 October 2012 - 05:13 PM
Could you create an example GIF/video of this in action? It would probably increase interest after they see what and how the lab part works.
I was planning on doing that. Maybe once I release V. 1.1.
billysback #9
Posted 18 October 2012 - 05:36 PM
The buttons don't seem to be working for me…
TangentDelta #10
Posted 18 October 2012 - 07:14 PM
The buttons don't seem to be working for me…
Are you using it on an advanced monitor?
billysback #11
Posted 18 October 2012 - 07:27 PM
Yes, I try clicking the buttons, above and below them as well as on them and nothing happens…
TangentDelta #12
Posted 19 October 2012 - 11:27 AM
Yes, I try clicking the buttons, above and below them as well as on them and nothing happens…

I bet you're using an older version of CC 1.45. You have to use pre-3, no other version will work.

Either that, or you're using an older version of AutomaPaint, and a newer version of 1.45.
TangentDelta #13
Posted 22 October 2012 - 09:46 PM
Sorry for the long time since and update. Work on 1.1.1 has been rather slow, since I feel like I'm sick with something.
TangentDelta #14
Posted 25 October 2012 - 01:50 AM
I have two more things left on my todo list for 1.1.2. If I have time tomorrow, I'll work on finishing up the new rule editor and rule reader.