It looks like you're new here. If you want to get involved, click one of these buttons!
Want to play the game without contesting? Here's a short code to copy:
function setup()
http.request("https://pastebin.com/raw/u5j4AS0R", function(d) loadstring(d)() setup() end, assert)
end
If you want to copy the game code and play it without internet connection, get the code here. Note! I have not implement an ending system yet, if you have issues with the code, please comment below!
Want to compete instead? Then this code is for you! Here's the start code to copy:
function setup()
http.request("https://pastebin.com/raw/M26reBtr", function(d) loadstring(d)() setup()
-- Edit the code below
-- Is called when the table is changed.
ai.on("placed", function(...)
local args = {...}
if #args == 4 then
elseif #args == 6 then
end
end)
-- Is called when it is your turn, no income parameters
ai.on("turn", function()
local x, y, v = math.random(2, 9), math.random(2, 9), math.random(0, 1)
ai.send("place", x, y, x+v, y+1-v)
end)
ai.on("error", function(code, err)
print(code, err)
end)
-- Edit the code above
end, assert)
end
If you have edited the code, post it below, we'll have temporary winners: If you post better code you're as long winner till someone updates your code to be even more better!
KNOWN ISSUES
ai.send("place", ...)
more than one time in ai.on("turn")
makes codea freeze. FIXED: Exit code 1
Comments
Events and Handlers and their Usage
There are two functions
ai.send
andai.on
that are important for you:ai.on(event, callback)
calls the callback function on the event call, whileai.send
sends an impulse to the client that he wants to try a specific operation.Protocol