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

New turtle competition-maze!

Started by Konlab, 24 May 2014 - 07:43 AM
Konlab #1
Posted 24 May 2014 - 09:43 AM
Competition ended:
-Nobody's turtle found exit from maze
-But there are some very good works (for example Bom Bloke's work)
Edited on 20 June 2014 - 09:32 AM
theoriginalbit #2
Posted 24 May 2014 - 10:01 AM
are you able to provide an example of the maze?
CometWolf #3
Posted 24 May 2014 - 10:46 AM

while true do
  turtle.dig()
  turtle.forward()
end
edit: lol, nvm i saw the no breaking blocks rule now :P/>
Edited on 24 May 2014 - 08:47 AM
theoriginalbit #4
Posted 24 May 2014 - 11:31 AM

while true do
  turtle.dig()
  turtle.forward()
end
edit: lol, nvm i saw the no breaking blocks rule now :P/>
close though.

while true do
  if not turtle.forward() then
    turtle.turnRight()
  end
end
done. :)/>
CometWolf #5
Posted 24 May 2014 - 11:33 AM
xxx
x x
x xxxx
x <- turtle enters here
x xxxx
x x
xxx

Would make him just go back and forth though :P/>
theoriginalbit #6
Posted 24 May 2014 - 11:55 AM
xxx
x x
x xxxx
x <- turtle enters here
x xxxx
x x
xxx

Would make him just go back and forth though :P/>
lol, use code tags to maintain those spaces :P/>
Konlab #7
Posted 24 May 2014 - 04:58 PM
But this maze will be 50 blocks wide, and theese programs will not working, so this will be challange, and the maze will be from bedrock, so the while true do turtle.dig() … Don't works!
theoriginalbit #8
Posted 25 May 2014 - 12:32 AM
But this maze will be 50 blocks wide, and theese programs will not working, so this will be challange, and the maze will be from bedrock, so the while true do turtle.dig() … Don't works!
without more details (and/or screenshot) of the maze my submission will be

while true do
  if not turtle.forward() then
    turtle.turnLeft()
  end
end
Dog #9
Posted 25 May 2014 - 01:23 AM
And, just in case going right is faster in this particular maze, I'll submit theoriginalbit's other suggestion


while true do
  if not turtle.forward() then
    turtle.turnRight()
  end
end

Although either of these can easily be fooled by a room with a single entry that isn't aligned with a corner of the room.
Edited on 24 May 2014 - 11:23 PM
Saldor010 #10
Posted 25 May 2014 - 01:59 AM
Ha! None of these will win, because what Konlab didn't say, was that none of the turtles would actually have fuel!
theoriginalbit #11
Posted 25 May 2014 - 02:03 AM
Ha! None of these will win, because what Konlab didn't say, was that none of the turtles would actually have fuel!
that's okay, they can just be spinning top Turtles :P/>
KingofGamesYami #12
Posted 25 May 2014 - 04:18 AM

local function refuel()
 while true do
  sleep(1)
  if turtle.getFuelLevel() < math.floor( turtle.getFuelLimit / 3 ) then
   turtle.refuel( 8 )
  end
 end
end
local function checkRight()
 turtle.turnRight()
 local block = turtle.detect()
 turtle.turnLeft()
 return block
end
local function main()
while true do
 if turtle.detect() then
  turtle.turnLeft()
  turtle.forward()
 elseif checkRight() then
  turtle.forward()
 end
end
end
parallel.waitForAny( main, refuel )
Tada, I made it out of the maze.
If you want to make this hard, do 3 dimensions.
Saldor010 #13
Posted 25 May 2014 - 02:50 PM
Okay, here's mine :P/>


os.pullEvent = os.pullEventRaw
while true do
  turtle.turnLeft()
  rednet.broadcast("DID I WIN?!")
  print("DID I WIN?!")
  sleep(0)
end
Edited on 25 May 2014 - 12:52 PM
Konlab #14
Posted 25 May 2014 - 02:53 PM
The turtles will have fuel :)/>
I will create a rednet receiver :)/>
And the maze will 10x10x10 block cube :P/>
flaghacker #15
Posted 25 May 2014 - 09:42 PM
Okay, here's mine :P/>/>


os.pullEvent = os.pullEventRaw
while true do
  turtle.turnLeft()
  rednet.broadcast("DID I WIN?!")
  print("DID I WIN?!")
  sleep(0)
end

You forgot to do rednet.open("right") :-P
Saldor010 #16
Posted 25 May 2014 - 09:46 PM
Okay, here's mine :P/>/>


os.pullEvent = os.pullEventRaw
while true do
  turtle.turnLeft()
  rednet.broadcast("DID I WIN?!")
  print("DID I WIN?!")
  sleep(0)
end

You forgot to do rednet.open("right") :-P

… shut up…
:P/>
valithor #17
Posted 25 May 2014 - 09:53 PM
Right wall rule in most 2 dimensional mazes you can win by keeping your hand on the right wall or in this case stay against the wall that is on your right when you first enter the maze.

following this rule it is really simple

while true do
	if turtle.forward()==true then
		turtle.turnRight()
		if turtle.detect()==true then

turtle.turnLeft()
end
elseif turtle.detect()==true then
turtle.turnRight()

if turtle.detect()==true then
turtle.turnLeft()
turtle.turnLeft()
end
end
end


edit:
Just now saw that the maze had been made 3 dimensional removed my submition
Edited on 30 May 2014 - 01:04 PM
KingofGamesYami #18
Posted 26 May 2014 - 03:25 AM
my revised submission! Note this script will be easily fooled.

function refuel()
 while true do
  sleep(1)
  if turtle.getFuelLevel() < math.floor( turtle.getFuelLimit / 3 ) then
   turtle.refuel( 8 )
  end
 end
end
local function checkRight()
 turtle.turnRight()
 local block = turtle.detect()
 turtle.turnLeft()
 return block
end
local function main()
while true do
 if not turtle.detectUp() then
  turtle.up()
  turtle.up()
 elseif turtle.detect() then
  turtle.turnLeft()
  turtle.forward()
 elseif checkRight() then
  turtle.forward()
 elseif not turtle.detectDown() then
  turtle.down()
  turtle.down()
 end
end
end
parallel.waitForAny( main, refuel )
Edited on 29 May 2014 - 01:50 PM
Bomb Bloke #19
Posted 28 May 2014 - 11:04 PM
I will create a rednet receiver :)/>

How about a GPS satellite?
TheOddByte #20
Posted 29 May 2014 - 03:24 PM
And, just in case going right is faster in this particular maze, I'll submit theoriginalbit's other suggestion


while true do
  if not turtle.forward() then
	turtle.turnRight()
  end
end

Although either of these can easily be fooled by a room with a single entry that isn't aligned with a corner of the room.
That wouldn't work! :P/>
But you pretty much already said that x)
Edited on 29 May 2014 - 01:26 PM
amtra5 #21
Posted 30 May 2014 - 12:21 AM

while true do
  turtle.turnRight()
  if turtle.detect() then
    turtle.turnLeft()
  end
  turtle.forward()
end
:P/>
CometWolf #22
Posted 30 May 2014 - 12:58 AM

while true do
  turtle.turnRight()
  if turtle.detect() then
	turtle.turnLeft()
  end
  turtle.forward()
end
:P/>
It's like you just said "Reading? Screw that, imma just post my idea!"

When will the maze be ready, Konlab?
Bomb Bloke #23
Posted 30 May 2014 - 01:17 AM
I assumed he was attempting to follow the running joke. It surprised me that anyone mentioned that "let's follow a wall" fallacy at all, let alone wrote code to perform it. I'd rather think they were all joking. :unsure:/>
Konlab #24
Posted 30 May 2014 - 05:36 PM
I'm building the maze currently.
TheOddByte #25
Posted 30 May 2014 - 10:47 PM
I assumed he was attempting to follow the running joke. It surprised me that anyone mentioned that "let's follow a wall" fallacy at all, let alone wrote code to perform it. I'd rather think they were all joking. :unsure:/>
I hope so too :P/>
Konlab, can you post a screenshot of the maze? :rolleyes:/>
Konlab #26
Posted 31 May 2014 - 01:20 PM
I assumed he was attempting to follow the running joke. It surprised me that anyone mentioned that "let's follow a wall" fallacy at all, let alone wrote code to perform it. I'd rather think they were all joking. :unsure:/>/>
I hope so too :P/>/>
Konlab, can you post a screenshot of the maze? :rolleyes:/>/>
Will be 2 categories: 2D and 3D.
If a program doesn't have turtle.up() or turtle.down() then its going in 2D maze.
If a program have turtle.up() or turtle.down() then its going in 3D cube-maze.
Screenshots will be only for cube-maze.
The turtles will begin in the center of maze facing north :)/>
The turtles will have fuel.
I will create a rednet receiver.
The turtle will be advanced turtle.

How big will the maze?
3D 10x10x10
2D 50x50
Turtles will have fuel?
Yes, at the beginning I will give him 15 coal.
Who win?
Who first come out of maze.
When will the competition?
In Juny.

And this is my code for 3D
while true do
if turtle.up() then
if turtle.forward() then
else
turtle.back()
else
turtle.down()
end
turtle.turnLeft()
a = math.random(1,2)
if a == 1 then
 turtle.turnRight()
else
 turtle.turnLeft()
end
end
Bomb Bloke #27
Posted 01 June 2014 - 02:55 AM
Screenshots will be only for cube-maze.

You'd mentioned you intended to make it out of obsidian - given that the turtles won't have digging tools anyway, how about glass? ThaumCraft has a wand of equal exchange that can be used to quickly change materials, if that's of any use to you.

Presumably there will be a video presentation at the end, or at least the opportunity to log into your world to watch?

I will create a rednet receiver.

Why? What's it going to do? If the turtle asks if it's out of the maze, how is it going to know what the answer is?

How about that GPS system?

I will give him 15 coal.

15 coal: 15 x 80 = 1200 movements.

2D maze: 50 x 50 = ~2500 possible movements, not accounting for additional backtracking.

3D maze: 10 x 10 x 10 = ~1000 movements, not accounting for additional backtracking.

Even assuming you're including the borders in those dimensions, I don't think that's enough fuel for either of the mazes. I'd say a stack of coal per turtle would be a better bet.

When will the competition?
In Juny.

June?

July?

:wacko:/>

And this is my code for 3D

A tip - if the turtle cannot go up, then it won't try to go forward. Thus if it's in a spot where it cannot go up or down, but only sideways, your turtle will simply sit and spin randomly in place while never traveling.
Edited on 01 June 2014 - 12:59 AM
TheOddByte #28
Posted 01 June 2014 - 12:26 PM
When will the competition?
In Juny.

June?

July?

:wacko:/>
Lol, Maybe it's something between those months x)
Juny! :P/>
Konlab #29
Posted 03 June 2014 - 05:12 PM
Answer for bomb bloke:
1.If I'll make a video.
2.I don't know :P/>
3.OK, 64 coal
4.Sorry, english isn't my first language, only fourth.
5.I'll fix my code

Thanks for suggestion Bomb Bloke ;)/>
Bomb Bloke #30
Posted 03 June 2014 - 05:34 PM
2.I don't know :P/>

Well, since I get the impression you're not interested in the GPS, how about this: if the turtle has a block in its inventory, then as it moves it can compare that to the blocks around it until it finds a match. All you'd need to do is place an identical block at the end of the maze.
Konlab #31
Posted 03 June 2014 - 05:38 PM
Well, I'm intrested for GPS, but its not new idea.
I had that idea older, a little bit.
Its good for finding lost turtles in 3D maze.
And… Now the rednet receiver seems to good idea…
Konlab #32
Posted 07 June 2014 - 09:29 AM
It seems noone (only me) want 3D maze, so the 2D maze is done, maybe this week will the competition.
Sorry, I tried I can't capture my screen, so video will be not :(/>
But I'll create some (some) screenshots :)/>
Bomb Bloke #33
Posted 07 June 2014 - 09:38 AM
I'd built a script to navigate your 3D maze, but it'll work in 2D so long as you apply a glass ceiling or something to stop it taking a shortcut across the top.

I'll PM you the source when you're ready to begin, then put it up publicly after it wins.
Emma #34
Posted 10 June 2014 - 05:27 PM
For the 2D Maze
Code:
Spoiler

stack={}
bt={}
stpos=0
dir=1 --1=up 2=right 3=down 4=left
xpos=1
ypos=1

turtle.select(1)

function rev()
  if dir==1 then
	return xpos,ypos-1  
  elseif dir==2 then
	return xpos-1,ypos
  elseif dir==3 then
	return xpos,ypos+1
  else
	return xpos+1,ypos
  end
end

function cdir()
  if dir ~= 4 then
	dir=dir+1
  else
	dir=1
  end
end

function been()
  local xo=0
  local yo=0
  if dir==1 then
	--return xpos,ypos-1  
	yo=1
  elseif dir==2 then
	--return xpos-1,ypos
	xo=1
  elseif dir==3 then
	--return xpos,ypos+1
	yo=-1
  else
	--return xpos+1,ypos
	xo=-1
  end
  for i=1,#bt do
	if bt[i][1]==xo+xpos and bt[i][2]==yo+ypos then
	  return true
	end
  end
  print("Wasnt at "..xo+xpos..","..yo+ypos)
  return false
end

function open()
  for i=1,4 do
	turtle.turnRight()
	cdir()
	if not turtle.detect() and not been() then
	  return true
	end
  end
  return false
end

function setDir(d)
  if dir==1 and d==2 then
	dir=d
	turtle.turnRight()
  elseif dir==1 and d==4 then
	dir=d
	turtle.turnLeft()
  elseif dir==2 and d==1 then
	dir=d
	turtle.turnLeft()
  elseif dir==2 and d==3 then
	dir=d
	turtle.turnRight()
  elseif dir==3 and d==2 then
	dir=d
	turtle.turnLeft()
  elseif dir==3 and d==4 then
	dir=d
	turtle.turnRight()
  elseif dir==4 and d==3 then
	dir=d
	turtle.turnLeft()
  elseif dir==4 and d==1 then
	dir=d
	turtle.turnRight()
  end
end

function pullStack()
  print("Stack Dir:"..stack[stpos][3])
  if stack[stpos][3]~=dir then
	setDir(stack[stpos][3])
  end
  turtle.back()
  cdir()
  cdir()
  addPos()
  xprev,yprev=rev()
  table.insert(bt,{xprev,yprev})
  print("Added "..xprev..","..yprev..","..dir)
  cdir()
  cdir()
  stpos=stpos-1
  print("Pulled from stack")
end

function addPos()
  if dir==1 then
	--return xpos,ypos-1  
	ypos=ypos+1
  elseif dir==2 then
	--return xpos-1,ypos
	xpos=xpos+1
  elseif dir==3 then
	--return xpos,ypos+1
	ypos=ypos-1
  else
	--return xpos+1,ypos
	xpos=xpos-1
  end
end

while not turtle.compareDown() do
  if turtle.forward() and not been() then
	stpos=stpos+1
	addPos()
	xprev,yprev=rev()
	stack[stpos] = {xprev,yprev,dir}
	table.insert(bt,{xprev,yprev})
	print("Added "..xprev..","..yprev..","..dir)
  else
	comp=false
	for i=1,4 do
	  turtle.turnRight()
	  cdir()
	  if not turtle.detect() and not been() then
		comp=true
		break
	  end
	end
	if comp==false then
	  repeat
		pullStack()
	  until open()
	end
  end
end
Konlab #35
Posted 10 June 2014 - 06:54 PM
WOW!!!
Maybe friday i'll test the codes!!!
Konlab #36
Posted 17 June 2014 - 03:59 PM
The competition ended:
Nobody get out from maze :(/>
a part of maze:

[attachment=1755:maze_small.JPG]
theoriginalbit #37
Posted 17 June 2014 - 04:03 PM
and this is why it was important that you show us the maze prior. otherwise you get to design the maze in such a way where we won't escape.
Bomb Bloke #38
Posted 17 June 2014 - 04:10 PM
I would've assumed that my script would've got out from the maze nearly right away; there's no roof, hence nothing stopping it from moving in three dimensions.

I guess you didn't try it. Though I can see a turtle sitting above the walls - I really don't know what to make of this…
Konlab #39
Posted 17 June 2014 - 04:26 PM
I edited the code; removed all turtle.up() and turtle.down() functions
I tried it, that turtle is out of fuel, and it turns around infinetly ( until terminating)

and this is why it was important that you show us the maze prior. otherwise you get to design the maze in such a way where we won't escape.
this isn't the entire maze



I guess you didn't try it. Though I can see a turtle sitting above the walls - I really don't know what to make of this…
That's my another turtle, there I written an another program until turtles tries to finish
Bomb Bloke #40
Posted 17 June 2014 - 04:31 PM
Those up/down calls weren't "optional". You'd've been better off rigging the detectUp/Down calls to always return true.

Or, I dunno, running my script as submitted. :P/>
theoriginalbit #41
Posted 17 June 2014 - 04:40 PM
the parameters for this competition just weren't defined enough. and yeah, you definitely shouldn't be editing submissions.
0099 #42
Posted 26 June 2014 - 05:24 PM
My program for 3D maze: http://pastebin.com/cuM9V7Me

P.S. I know, that it is full of crazy coroutine stuff, but… I'm just learning coroutines :D/>
P.P.S. I suppose, the worst maze for my program is a maze with repetative structures, because this turtle decided to never ever repeat itself.
Bomb Bloke #43
Posted 27 June 2014 - 02:23 AM
So you're saying that if the turtle ever needs to do a 180, it'll instead give up? :unsure:/>

I guess at this stage I might as well reveal my code.

It works by moving the turtle around the maze semi-randomly (it'll generally try to head towards the maze exit, assuming it's got GPS access and knows where that exit is). Whenever it detects that it could change direction, it registers that junction's position as a "node".

Nodes go in a list alongside information about which other nodes were traveled from to get to them. If the turtle ever hits a dead end, the turtle can refer back to that node list to determine an exact path back to the nearest junction which still has unexplored paths available. In my tests this system could easily path to most any point in my maze even after recording well over a hundred nodes.

There's room for improvement, though I'd be honestly surprised if there's a maze it can't solve. Node loops and whatnot are obviously accounted for. Granted, there'd be a size limit (the pathfinding function's recursive, though the turtle does try (ineffectively, but it tries) to delete nodes from the table once it determines they don't go anywhere, extending its range somewhat), but that aside it should be impossible to confuse.

… um, assuming people don't randomly delete bits of its code. If for whatever reason you want to force it to operate in 2D, and can't be bothered making a maze which does that (by building a roof/floor), then replace the "turtle.detectUp()" and "turtle.detectDown()" calls with "true".
0099 #44
Posted 27 June 2014 - 08:40 PM
So you're saying that if the turtle ever needs to do a 180, it'll instead give up? :unsure:/>

No, I'm saying that it's guaranteed that the turtle will never run in circles. At any moment of time, there is a finite number n, and a turtle will try all possible cobminations of length n without repeating. When and only when it runs out of combinations, n increases by 1. It's all determined, there is a determined sequence of numbers and set of rules that converts a number into direction of the turn. But that sequence is like a non-periodic decimal fraction - it is infinite and never repeats. Even the math.random() function eventually begins to repeat. And sometimes the length of its "period" gets critically small. That's because I use my own sequence. My programs gives up when n gets to one million. But this will happen in a very very long time.