Jump to content


Buho's Content

There have been 13 items by Buho (Search limited from 10-February 22)


By content type

See this member's

Sort by                Order  

#210712 Ranged Turtle

Posted by Buho on 23 March 2015 - 12:59 PM in Suggestions

You mean a turtle sending redstone pulses to a dispenser?

while true do
	redstone.setOutput("bottom", true)
	redstone.setOutput("bottom", false)
end



#209152 Worst language

Posted by Buho on 11 March 2015 - 06:38 PM in General

This is probably because there was no Internet back then :D

Good luck!



#208800 Worst language

Posted by Buho on 09 March 2015 - 05:13 PM in General

I think I learned how to program with Karel in my high school! It would have been around 1995. After completing a semester learning GW-BASIC and Q-BASIC, we could take the advanced class with PASCAL. The curriculum used a pseudo environment with a robot, named Karel, not unlike ComputerCraft (which was one of my initial draws to CC).

I remember being frustrated by this at the time, sensing I wasn't in a "real" programming world but instead in a sandbox where I could only control a robot. Nevertheless, it was instructive. Googling around, I found an explanation for why Karel is used: http://math.otterbei...relOverview.htm Click "Home" for screenshots and more information.

No, Karel is not an esoteric language. It is just constructed to emphasize certain things the teacher wants students to learn, I think. For me, the lessons worked and I fell in love with programming.

This class was pivotal and I decided to go to college and get a Computer Science degree. Midway through college I switched to Information Systems (CS had too much theory, not enough application), I got a BS in that, and I've been a professional programmer now for 14 years. I still love going into work every single day!

I love my job, and how I explain why I like what I do to non-programmers hails back to Karel: computers are like robots, and I like making robots do repetitive stuff to make my life easier.



#199396 Need help with turtle program

Posted by Buho on 26 November 2014 - 04:27 PM in Ask a Pro

EDIT: I was going off the first post, not the 2nd post which I didn't see.

First of all, shell.run("move", x, y) will not do what you think it will do. Just off the top of my head, this would be similar to what you want, though there are probably more efficient ways of doing things:

local function forward(dist)
	for x = 1, dist do
   	 while not turtle.forward() do --Tries to move forward 1, if it fails, it will keep trying until it succeedes
			--You may want to put turtle.dig() in here to clear out gravel (and simplify your code)
			--You may want to put turtle.attack() in here to get rid of mobs in the way
			os.sleep(1)
		end
	end
end

local function move(dir, dist)
	if dir == "f" then forward(dist) end
	if dir == "r" then turtle.turnRight() end
	if dir == "l" then turtle.turnLeft() end
end

That's just something to get you started using the Turtle API.

Regarding your specific problem, d is undefined, and so is bit.band(), I think. Here's what I use in my zig-zag algorithms (using the forward() function above, but one that includes a turtle.dig()):

	if x < width then --Do not go beyond the bounds if last row
		if x % 2 == 0 then
			turtle.turnLeft() --Turn left (assuming 1st row is x=1)
	 	   forward(1)
	 	   turtle.turnLeft()
		else
	 	   turtle.turnRight() --Turn right
	 	   forward(1)
	 	   turtle.turnRight()
		end
	end

A similar pattern for z can be done since it's similar to x and you don't want to descend too far down.

Also, since the forward() function has a distance parameter, you don't need the y variable anymore. Just call forward(length - 1) with a dig line inside forward(). (The -1 is because you're starting on the 1st spot.)

Finally, a tip, in Minecraft, z refers to a horizontal dimention, not the vertical dimension. In my own programs, I treat z as "forward" in local/relative coordinate space (with x as "rightward" and y as "downward" or "upward"). Using z as a vertical unit may confuse you or others in the future. Just something to keep in mind. As variables, it won't change how your program behaves.

Your first program is off to a great start, Shawn!



#199267 Strategy to clear water

Posted by Buho on 25 November 2014 - 04:07 PM in Ask a Pro

Lyqyd, I tried your strategy and it works great. I think it failed on my tunnel project because I had an open side. The perimeter needs to be built first, then the insides traversed. And I like the idea of building the dome top-down. I was originally thinking bottom-up before but it makes more sense to deal with water removal in a downward direction. I'm so glad a simple traversal will clear the water instead of a two-step process!

BB, I clear out lava streams in the nether by systematically traversing them downward with a turtle. But I'll keep this in mind. My test just now was with a 4 block radius circle. It might fail on, say, a 100 radius circle.

Thanks, all.



#199181 Vertical shaft (rabbit hole) ore miner

Posted by Buho on 24 November 2014 - 02:51 PM in Turtle Programs

This is similar to my tried-and-true mining program that I've been using for over a year. It digs a "rabbit hole" down, checks all walls, until it hits bedrock. Then it moves up 5, forward 5, down to bedrock (to account for the "roughness" of bedrock), and then digs up to the surface (or starting level), checking all walls. At the surface, it moves forward 5 and repeats until a specified distance is reached. Then it moves over one, shifts forward or back (to create the offset pattern) and returns. It then shifts right again, forward or back (for the pattern), and repeats.

At the beginning I specify the dimensions of this mining field. I typically specify 10x80 with other turtles running in parallel. A top chest for fuel is not needed since in the overworld it can refuel with found coal. I don't have ender chests that are usable for turtles, so it returns back to that first chest when there is less than two slots free. Transmission of progress through rednet allows me to monitor them from a central computer.

The biggest problem with my program is retrieving turtles after Minecraft crashes. I'm recording position and direction for such an event, so they can come home from the depths of the ground, but it seems Minecraft loves to crash between the writing to file and the turtle.turnRight(). GPS is unpractical since I'm usually deploying from y=16 and don't want to poke holes in the ceiling to launch a GPS array.

The second biggest problem with my program is setup. Setting the initial position, inventory, and command-line parameters is time-intensive when you have 16 running in parallel. I'm working on a deployment program from a master computer to automate this setup.



#199177 Strategy to clear water

Posted by Buho on 24 November 2014 - 02:18 PM in Ask a Pro

Hey all. I'm stumped on coming up with a good strategy to clear water. The strategy to hollow out a cave is to simply traverse the volume with your turtle, but that fails with water.

My specific application involves creating a room of air in an ocean. It's going to be a very large room, so filling it with sand and then removing it isn't very desirable from a time perspective, but if there isn't a faster strategy, that'll have to do.

More specifically, I'm planning on writing a program to construct a spherical glass dome in the ocean rising from bedrock to above sea level. The slanted underwater walls present unique challenges. I'd rather not drain a column of water that is the dome's footprint, as then I'd have to refill portions with water (not to mention I'd be destroying part of the ocean floor). But then I'm not sure how to get rid of the water under the dome.

I'm sure this is a common design problem this community has run into before, but I'm not sure how to search for it on this forum. I ran into a similar situation a few months ago when I constructed a half-dome glass tube for ocean boat entry to an underground cave. In that case as I built each layer of the descending tube, I filled it with dirt and then removed it. That took twice as long to construct, and was unneeded once I dropped below the ocean floor.



#195200 What are you planning to do with the new Computercraft 1.64 features?

Posted by Buho on 04 October 2014 - 05:08 PM in General

I'm really surprised by these new features! I can easily imagine this being suggested and shot down. Maybe it already was!

That said, I'm glad they were included! :)



#186489 Breaking ice into water

Posted by Buho on 01 July 2014 - 11:56 PM in Suggestions

Okay, this is a bug then. I trued turtle.digDown() on ice that's sitting on dirt and it just destroyed the ice block.



#186402 Breaking ice into water

Posted by Buho on 01 July 2014 - 03:48 PM in Suggestions

You know what? That's it. There's no block under it at the moment of breaking! I'm building from underneath, the step right after breaking the ice is to place a block under it! Ha! Sorry about that, all. Gonna tweak my algorithm now.



#186397 Breaking ice into water

Posted by Buho on 01 July 2014 - 03:06 PM in Suggestions

@theoriginalbit: Another program I wrote months ago built a sugar cane farm and this is exactly what I did with two buckets, placing them in an alternating pattern exploiting the infinite water feature. For my current project I was too lazy to deal with that and figured ice would be easier.



#186395 Self-Replicating Turtle - Revisited

Posted by Buho on 01 July 2014 - 03:01 PM in Turtle Programs

Awesome work! I'm blown away! I read that old thread last year and was dismayed nobody completed it.

Keep in mind, if the player doesn't move very much (sits still), turtles can move infinitely in any direction with no problems.

Looking forward, I'd love to see the one or two new turtles fueled up to the max, given a starting inventory, and then sent off into the wild, seeking a suitable place to replicate again! For purity, the program could be identical to its parent, but having a given inventory would simplify derivative generations. Perhaps send Miner2 in one direction and the parent in the opposite direction, while Miner3, if it exists, does something like tree farming. A fractal pattern could be made so children don't tread on old ground.



#186375 Breaking ice into water

Posted by Buho on 01 July 2014 - 01:25 PM in Suggestions

I wrote a program to construct a tree farm. Part of the process involved laying a row of ice that the turtle would break to form a water stream. I was really surprised to find that when turtle.dig() on ice converted the block into air, not water. I ended up modifying my program so it didn't break the ice, leaving that "finishing touch" to me.

The logical thing, as it seems to me, is a turtle with an unenchanted pickaxe, should change ice into water, like a normal pickaxe, not destroy ice.

This is a really small suggestion, and I have an easy workaround in this instance. I'm more interested in why this mechanic is the way it is. I thought CC determined what to do based on the properties of an unenchanted diamond pickaxe.