From 4f54dfb8d75b6642e48659c1aeb541e1e3fe3f13 Mon Sep 17 00:00:00 2001 From: Aayush Chadha Date: Sat, 15 Dec 2018 01:15:07 +0530 Subject: [PATCH 1/2] Add createChangeMsg --- lua-agent/protocol.lua | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/lua-agent/protocol.lua b/lua-agent/protocol.lua index af6ebf5..69efe63 100644 --- a/lua-agent/protocol.lua +++ b/lua-agent/protocol.lua @@ -67,19 +67,19 @@ function protocol.evaluateStartMsg(message) end end ---function protocol.createChangeMsg(move, board) --- local boardCopyString = board:toShortString() -- Get the short string of boardCopy ----- log.debug('Board after:', boardCopyString) --- local moveHole = move:getHole() --- local change = 'CHANGE;' --- local turns = { --- you = ';YOU', --- opp = ';OPP', --- endTurn = ';END' --- } ----- log.info('Returning msg: ', change .. moveHole .. ';' .. boardString .. ';OPP' .. '\n') --- return change .. moveHole .. ';' .. boardCopyString .. ';OPP' .. '\n' ---end +function protocol.createChangeMsg(move, board) + local boardCopyString = board:toShortString() -- Get the short string of boardCopy +-- log.debug('Board after:', boardCopyString) + local moveHole = move:getHole() + local change = 'CHANGE;' + local turns = { + you = ';YOU', + opp = ';OPP', + endTurn = ';END' + } +-- log.info('Returning msg: ', change .. moveHole .. ';' .. boardString .. ';OPP' .. '\n') + return change .. moveHole .. ';' .. boardCopyString .. ';OPP' .. '\n' +end function protocol.evaluateStateMsg(message, board) -- log.info("BOARD RECEIVED", board:toString(), board) From b7f0715e9d9205f7ff54dc3390e1b2cec8659a13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hendrik=20M=C3=B6lder?= Date: Fri, 14 Dec 2018 21:53:45 +0200 Subject: [PATCH 2/2] Build cleanup --- lua-agent/protocol.lua | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/lua-agent/protocol.lua b/lua-agent/protocol.lua index 69efe63..3e73d8e 100644 --- a/lua-agent/protocol.lua +++ b/lua-agent/protocol.lua @@ -69,20 +69,18 @@ end function protocol.createChangeMsg(move, board) local boardCopyString = board:toShortString() -- Get the short string of boardCopy --- log.debug('Board after:', boardCopyString) local moveHole = move:getHole() local change = 'CHANGE;' + --luacheck: ignore turns local turns = { you = ';YOU', opp = ';OPP', endTurn = ';END' } --- log.info('Returning msg: ', change .. moveHole .. ';' .. boardString .. ';OPP' .. '\n') return change .. moveHole .. ';' .. boardCopyString .. ';OPP' .. '\n' end function protocol.evaluateStateMsg(message, board) --- log.info("BOARD RECEIVED", board:toString(), board) -- Check if message has a valid ending character if message:sub(#message, #message) ~= "\n" then return nil end @@ -116,14 +114,12 @@ function protocol.evaluateStateMsg(message, board) board:setSeeds(Side.NORTH, hole, boardParts[hole]) -- South holes board:setSeeds(Side.SOUTH, hole, boardParts[hole + board:getNoOfHoles() + 1]) --- log.debug("Updating board\n", board:toString()) end -- North store board:setSeedsInStore(Side.NORTH, boardParts[board:getNoOfHoles()+1]) -- South store board:setSeedsInStore(Side.SOUTH, boardParts[2 * board:getNoOfHoles() + 2]) --- log.info('Board:\n', board:toString()) -- msgParts[4] -- who's turn moveTurn.endMove = false @@ -139,7 +135,6 @@ function protocol.evaluateStateMsg(message, board) return nil end --- log.debug("Function completed. Returning moveTurn.") return moveTurn end