hczhcz / mese-next

The modern variant of "Management and Economics Simulation Exercise"

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Engine release

emanuelstanciu opened this issue · comments

Hello,

Great finding this project that is an upgrade on the original MESE game created by/for Junior Achievement.
I would like to create a docker image for this, a one stop shop to bring everything up and start playing.

Any chance you can send me the Engine part?

Thank you.

commented

Thank you for your interest. I uploaded the binary file of the engine in this repo and it works on Linux amd64. If you will use it on some other platform, please feel free to let me know.

Please notice that, since the engine may have some copyright issue, please do not use it for commercial purpose unless JA allows that.

I am looking forward for your docker implementation @emanuelstanciu. Personally it was not working for me when i tried it on Ubuntu. The login page would just not take me anywhere. I also wonder if there is any documentation for the engine. I have some very nice memories from this simulation game, I would like to try it out again soon.

commented

@shpati Login with username "admin" and password "echopen" (see config.js) and you will see the admin panel.

commented

BTW, there is a Telegram bot @mese_bot which runs the engine.

@hczhcz I have used the login details from config.js but the page gets me nowhere, it gets stuck in login and does not go any further.

commented

@shpati Did it show error messages in terminal and/or browser console?

No, nothing. The engine seems to work in Ubuntu 16.04 though, I can see the list of commands available, but I have no documentation for using them. I wonder if it works for you @emanuelstanciu? If yes, then it must be my setup.

commented

If the server works, when you open the web page (127.0.0.1:63000), the log will be like:

[2017.12.10 15:15:26.349] db init mongodb://localhost/mese
[2017.12.10 15:15:26.393] server init 63000
[2017.12.10 15:15:26.397] socket init
[2017.12.10 15:15:26.409] ready
[2017.12.10 21:45:33.646] web ::ffff:127.0.0.1 /
[2017.12.10 21:45:35.367] web ::ffff:127.0.0.1 /style.css
... (some other web requests)
[2017.12.10 21:45:36.087] connect ::ffff:127.0.0.1

Do the "web" and "connect" lines show up on your computer @shpati?


Here are some examples of using the engine:

./mese init 8 modern > game1 # initialize a 8-player game
./mese init 8 modern | ./mese alloc | ./mese alloc | ./mese alloc > game1 # initialize a 8-player game with 3 periods (quarters)
./mese print_player 0 < game1 # output the first player's report (in JSON format)
./mese submit 5 2 65 500 3000 15000 10000 < game1 > game1 # submit the sixth player's P2 decision (game starts from P2)
./mese close < game1 > game1 # close the current period

The log looks exactly as you describe it @hczhcz . There are both connect and web lines showing up. The web lines show up upon opening/refreshing the browser to the login page. The connect lines are flooding the terminal screen though, I wonder if this is normal at about 80 connect lines/second.

The engine works properly, I tried some of your examples above. Do you have some more comprehensive documentation on the engine commands?

Btw, I am accessing the login page in Firefox 57.0.

More details:

package.json

{
  "name": "mese-next",
  "version": "1.0.0",
  "private": true,
  "dependencies": {
    "compression": "^1.7.1",
    "express": "^4.16.2",
    "mongodb": "^2.2.33",
    "socket.io": "^2.0.4"
  }
}

config.js

'use strict';

module.exports = {
    db: 'mongodb://localhost/mese',
    port: 63000,

    adminUser: 'admin',
    adminPassword:
    '\xad\xbd\x18\x3e\x60\xba\x28\x6f'
    + '\x2a\x36\xa4\x3b\xe5\xaf\x11\xfe'
    + '\xa4\x1a\xe9\x9f\x7d\xb4\x35\xfd'
    + '\x6d\x86\x3c\x30\x4f\xb7\xe1\xfc', // 'echopen',

    meseEngine: './mese',
    meseMaxPlayers: 32,
    meseMinDataSize: 4096, // for db data protection

    rtmeseDelta: 0.01,
    rtmeseInterval: 1000,
    rtmeseMaxPlayers: 32,
};

mongod
mongod --bind_ip=0.0.0.0 --dbpath=data --nojournal --rest "$@"

commented

@shpati Thanks for the details you provided! The flooding "connect" lines indicate that the version of socket.io installed by npm is not compatible with the version of the one used in the webpage (/lib/socket.io.min.js).

I pushed several commits. Now the socket.io client is loaded from the server-side package and it would not be a problem anymore.
Please note that MongoDB is also upgraded to 3.0.x in the recent commits. I am not sure if it works with 2.2.x mongod.

The package versions I just tested:

"compression": "1.7.1",
"express": "4.16.2",
"mongodb": "3.0.0-rc0",
"socket.io": "2.0.4",

I will add more details about the engine later (probably on the repo wiki).

@hczhcz it seems to be working now! I managed to get into the admin panel :)

However, the following changes are necessary:

  1. Add empty data directory in the main folder. If not the server will not start.
  2. Start the mongodb server using the following command (please correct me on this @hczhcz ):
    mongod --bind_ip=127.0.0.1 --dbpath=data

So, now after being able to create Games, Users, assigning games to users and allocating periods (seems to be no limit there), I will patiently wait for you to implement the game functionality so I can finally play a little :)

commented

@shpati Game functionality has already been implemented. But there might be some compatibility problems.

Here is the screenshot after I created a game "test10" in the admin panel, login to the user "hcz" and click on the game ("test10" button on the bottom-left):

screenshot from 2017-12-12 12-32-12

The log:

[2017.12.12 12:31:15.414] [admin] admin auth
[2017.12.12 12:31:15.423] [admin] list games
[2017.12.12 12:31:15.446] [admin] admin list all
[2017.12.12 12:31:27.364] [admin] list games
[2017.12.12 12:31:29.685] [admin] admin init game test10 modern
[2017.12.12 12:31:29.686] [admin] allocated 8pd
[2017.12.12 12:31:29.687] exec ["init",1,"modern"]
[2017.12.12 12:31:29.691] exec ["alloc"]
[2017.12.12 12:31:29.694] exec ["alloc"]
[2017.12.12 12:31:29.697] exec ["alloc"]
[2017.12.12 12:31:29.701] exec ["alloc"]
[2017.12.12 12:31:29.704] exec ["alloc"]
[2017.12.12 12:31:29.709] exec ["alloc"]
[2017.12.12 12:31:29.713] exec ["alloc"]
[2017.12.12 12:31:29.721] [admin] invited hcz
[2017.12.12 12:31:45.726] [admin] login hcz
[2017.12.12 12:31:45.731] [hcz] list games
[2017.12.12 12:31:48.026] [hcz] get report test10
[2017.12.12 12:31:48.027] exec ["print_player",0]
[2017.12.12 12:31:57.378] [hcz] get report test10
[2017.12.12 12:32:27.395] [hcz] list games
[2017.12.12 12:32:27.466] [hcz] get report test10
[2017.12.12 12:32:57.379] [hcz] get report test10
[2017.12.12 12:33:27.364] [hcz] list games
[2017.12.12 12:33:27.378] [hcz] get report test10
[2017.12.12 12:33:57.379] [hcz] get report test10

On my computer (Linux Mint 18), mongod is a background service come with default settings:

dbpath=/var/lib/mongodb
logpath=/var/log/mongodb/mongodb.log
logappend=true
bind_ip = 127.0.0.1
journal=true

It works now, the log helped. The issue was that in the Players field, part of the New Game section I was entering the number of players, whereas in fact I should have entered the player names separated by a comma (admin,test_user,etc).

Now it works fine, you have done a good job @hczhcz ! The game is already playable :)

One bug I noticed is the period number mismatch between the page header and the screen message, after the first period I believe it happens. Also some typos in the messages.

commented

The period number on the page header is "the period number of the report" while the one on the message is "the period to submit a decision". The message was not clear enough :-)