Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to simulate a match with two player using LUA client #2

Closed
takaaptech opened this issue Sep 29, 2015 · 8 comments
Closed

How to simulate a match with two player using LUA client #2

takaaptech opened this issue Sep 29, 2015 · 8 comments

Comments

@takaaptech
Copy link
Contributor

Hi,
Can you explain how to setup two player playing Checkers game or a player play with an AI using LUA?

I just run: lua ./main.lua -s localhost -p 3000 -n taka Checkers
and it shows:
connecting to: localhost:3000
successfully connected to server...
In Lobby for game 'Checkers' in session '2'

And then i create new terminal and run the same command as above, and then it shows: (It seems to game start and then over immediately)

connecting to: localhost:3000
successfully connected to server...
In Lobby for game 'Checkers' in session '2'
Game starting
Game is over. I Won! because: All enemy checkers jumped

(In 1st terminal, it shows: Game starting
Game is over. I Lost :( because: No checkers remaining
)
In server side:
Checkers - 2 @ 1043 Received new connection!
Checkers - 2 @ 1043 Received new connection!
Checkers - 2 @ 1043 Game is starting.
Checkers - 2 @ 1043 Game is over.
Checkers - 2 @ 1043 Client Checkers Lua Player disconnected
Checkers - 2 @ 1043 Client Checkers Lua Player disconnected
Lobby @ 1008 Game Session @ 1043 exited

Thanks very much!

@JacobFischer
Copy link
Member

That all looks correct to me. Two Lua clients connected and played 'Checkers' in game session '2'.

I've added a markdown doc the the parent repo, Cadre here:

https://github.com/JacobFischer/Cadre/blob/master/howToPlay.md

It details, with screenshots, what (and to some extend why and how) to do to play games using Cadre.

Does this new document help you?

@takaaptech
Copy link
Contributor Author

That's awesome! That document help me so much! Now i can understand that two client play by AI. But after match end, nothing in my output/gamelogs folder, so i can not see match detail on web under "Game Archieves". So can you take a look at that?

@takaaptech
Copy link
Contributor Author

And if i try to use --log flag, it shows:

taka$ sudo node main.js --log
/Users/taka/Downloads/Cerveau-master/gameplay/log.js:52
_obj.filename = (_obj.filename || ("output/logs/log-" + _obj.server.name.replace(/ /g, ".") + "-" + utilities.momentString() + ".txt"));
^

ReferenceError: utilities is not defined
at Object._obj.log (/Users/taka/Downloads/Cerveau-master/gameplay/log.js:52:109)
at log (/Users/taka/Downloads/Cerveau-master/gameplay/log.js:16:10)
at Object.Class._initializeGames (/Users/taka/Downloads/Cerveau-master/gameplay/lobby.js:76:13)
at Object.Class.init (/Users/taka/Downloads/Cerveau-master/gameplay/lobby.js:36:14)
at Object.newClass as _mainClass
at Object. (/Users/taka/Downloads/Cerveau-master/main.js:31:13)
at Module._compile (module.js:434:26)
at Object.Module._extensions..js (module.js:452:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)

@JacobFischer
Copy link
Member

Hmm. That's weird. Files should be generated in Cadre/Cerveau/output/gamelogs after you play a game. Make sure there's read/write access to those folders? What OS are you using?

The code for saving gamelogs happens in Cadre/Cerveau/gameplay/gameLogger.js:55 in the log:function (gamelog) function. Surprising I know. I've attached an error handler in case saving the gamelog generates. Maybe I did that wrong.

You could try this:
In Cadre/Cerveau/gameplay/gameLogger.js on line 63 where is says:

        var gzip = zlib.createGzip();

        gzip.on("error", function(err) {
            log.error("Could not save gamelog '" + gamelog.gameName + "' - '" + gamelog.gameSession + "'.", err);
        });

add in another error handler like this:

        var gzip = zlib.createGzip();

        // maybe the writeStream need an error handler?
        writeSteam.on("error", function(err) {
            log.error("Could not save gamelog '" + gamelog.gameName + "' - '" + gamelog.gameSession + "'.", err);
        });

        gzip.on("error", function(err) {
            log.error("Could not save gamelog '" + gamelog.gameName + "' - '" + gamelog.gameSession + "'.", err);
        });

See if that catches the error for you.


As for the --log error, thanks for catching that. I have no idea why I commented out the utilities require up top, but I fixed it in in my most recent Cerveau commit.

Now console output should be logged in Cadre/Cerveau/output/logs/. See if that works too, or if those output files too won't generate for you.

@takaaptech
Copy link
Contributor Author

--log works with logged log-Lobby.@.1056-2015.10.01.00.17.30.271.txt and log-Checkers.-.1.@.1074-2015.10.01.00.18.41.554.txt
But gamelogs still empty. I run server on macos and with sudo then i think it read and write as normal. I will take a look at gameLogger.js later. Thank so much!

@JacobFischer
Copy link
Member

So I've actually never tested Cerveau on Mac OS X. It could be an error there only on that OS. On Linux and Windows it works fine.

@takaaptech
Copy link
Contributor Author

OK I just try to debug by print log to console and see that: line 167 of session.js run as normal:
gamelog: this.generateGamelog()
print inside generateGamelog works.
But line 55 in gameLogger does not run:
log: function(gamelog)

That means i guest that process.send can not reach to gamelog?

I test it by print to console. Maybe would you please teach me how to setup debug or using debug tool in nodejs. So i can help you to find some bugs in mac os. :)

@JacobFischer
Copy link
Member

I created a new issue in the server repo at siggame/Cerveau#2 that documents this error better, hopefully I can find a siggame dev with a mac computer to find the bug.

If you want to try to find this error I debug Cerveau using the wonderful node-inspector, though debugging on multiple threads is hackish.

I'm closing the issue here as it does not appear to (and I have no idea how it could) be an issue with this Lua client.

Thanks for all your support in finding these bugs, and I invite you to continue taxing this framework as I've moved it to my development organization it was originally intended for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants