I need to pass a variable length array in which each element is a tuple of two integers. As an example:
path = [(1,1),(1,2)]
path = [(1,1),(1,2),(2,2)]
I try to use the package and unzip, however, since the array has different lengths, I don’t know how to create a format so that both know the format. I tried to turn it into a single line with delimiters, for example:
msg = 1&1~1&2~
sendMsg = pack("s",msg) or sendMsg = pack("s",str(msg))
on the receiving side:
path = unpack("s",msg)
but it just prints 1 in this case. I also tried sending 4 integers that send and receive a penalty if I do not include an extra line representing the path.
sendMsg = pack ("hhhh", p.direction [0], p.direction [1], p.id, p.health)
on the receiving side:
x,y,id,health = unpack("hhhh",msg)
, "hhhhs", .
. 2D- int, , "" .
.