moveList.sort(key = lambda e : e["score"], reverse=True)
#sys.stderr.write("vixen - best move: " + str(moveList[0]["unit"].x) + " " + str(moveList[0]["unit"].y) + " " + moveList[0]["direction"] + " [ score = " + str(moveList[0]["score"]) + " ]\n")
- if moveList[0]["score"] == 0:
- print "NO_MOVE"
- return True
+ #if moveList[0]["score"] == 0:
+ # print "NO_MOVE"
+ # return True
print str(moveList[0]["unit"].x) + " " + str(moveList[0]["unit"].y) + " " + moveList[0]["direction"]
struct protoent * tcp = getprotobyname("tcp");
sfd = socket(PF_INET, SOCK_STREAM, tcp->p_proto);
- if (sfd == -1)
+ if (sfd < 0)
{
- fprintf(stderr, "NetworkController::NetworkController - couldn't create a TCP socket!");
+ // fprintf(stderr, "NetworkController::NetworkController - couldn't create a TCP socket!");
+ perror("NetworkController::NetworkController - creating TCP socket... ");
return;
}
}
{
if (shutdown(sfd, SHUT_RDWR) == -1)
{
- fprintf(stderr, "NetworkController::~NetworkController - Can't shutdown socket %d!", sfd);
+ // fprintf(stderr, "NetworkController::~NetworkController - Can't shutdown socket %d!", sfd);
+ perror("NetworkController::~NetworkController - shutting down socket... ");
close(sfd);
sfd = -1;
}
ipa.sin_addr.s_addr = INADDR_ANY;
memset(&ipa,0, sizeof ipa);
- if (bind(sfd, (struct sockaddr*)&sfd, sizeof sfd) == -1)
+ if (bind(sfd, (struct sockaddr*)&ipa, sizeof (ipa)) == -1) //dERP DERP DERP
{
- fprintf(stderr, "Server::Server - Couldn't bind to socket! Abort\n");
+ // fprintf(stderr, "Server::Server - Couldn't bind to socket! Abort\n");
+ perror("Server::Server - binding to socket... ");
close(sfd);
sfd = -1;
return;