-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInterface.lua
More file actions
63 lines (48 loc) · 984 Bytes
/
Copy pathInterface.lua
File metadata and controls
63 lines (48 loc) · 984 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
-- Blind ant on squares grid interface
--[[
Author: Martin Eden
Last mod.: 2026-06-15
]]
local Directions =
{
{ 1, 0 },
{ 0, 1 },
{ -1, 0 },
{ 0, -1 },
}
local Interface =
{
-- [Methods]
Step =
function(Me)
local Direction = Directions[Me.direction]
for i = 1, #Me.Position do
Me.Position[i] = Me.Position[i] + Direction[i]
end
end,
TurnLeft =
function(Me)
local direction = Me.direction
direction = direction + 1
if (direction == 5) then direction = 1 end
Me.direction = direction
end,
TurnRight =
function(Me)
local direction = Me.direction
direction = direction - 1
if (direction == 0) then direction = 4 end
Me.direction = direction
end,
-- [State]
direction = 1,
Position = { 0, 0 },
}
-- Export:
return Interface
--[[
2026-01-21
2026-06-01
2026-06-04
2026-06-15
]]