Giter VIP home page Giter VIP logo

gridworld's Introduction

Clusterio gridworld

Automatic gridworld configuration

Installation

Dependencies:

Run the following commands in the folder Clusterio is installed to:

npm install @danielv123/gridworld
npx clusteriocontroller plugin add @danielv123/gridworld

Substitute clusteriocontroller with clusteriohost or clusterioctl if this a dedicated host or ctl installation respectively.

Visualization of this repo

Development setup

Clone the repository in clusterio/external_plugins/

git clone https://github.com/clusterio/clusterio
cd clusterio/external_plugins
git clone https://github.com/Danielv123/gridworld
git clone https://github.com/clusterio/edge_transports
cd ..
pnpm install

Interactive:

node packages/create --dev

node packages/ctl plugin add ./external_plugins/gridworld
node packages/ctl plugin add ./external_plugins/edge_transports
pnpm install @hornwitser/server_select -w
node packages/controller bootstrap create-admin Danielv123
node packages/controller bootstrap create-ctl-config Danielv123
node packages/controller plugin add @hornwitser/server_select
node packages/controller plugin add ./plugins/global_chat
node packages/controller plugin add ./plugins/inventory_sync
node packages/controller plugin add ./plugins/player_auth
node packages/controller plugin add ./plugins/research_sync
node packages/controller plugin add ./plugins/statistics_exporter
node packages/controller bootstrap generate-user-token Danielv123 > token.txt
node packages/controller run --dev --dev-plugin gridworld

Log into the webui with the token in token.txt and create a new host token with id 1 then run the following in terminal to setup the host:

wget -O factorio.tar.gz https://www.factorio.com/get-download/latest/headless/linux64
tar -xf factorio.tar.gz
node packages/host config set host.id 1
node packages/host config set host.controller_token xxxxxxxxxxxxxxxxxxxxx
node packages/host config set host.name "Host 1"
node packages/host config set host.public_address "localhost"

Luacheck can be downloaded from https://github.com/mpeterv/luacheck/releases/download/0.23.0/luacheck.exe or sudo apt install lua-check or brew install luacheck

Put it in your %path% and run luacheck ./module

gridworld's People

Contributors

danielv123 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

gridworld's Issues

Map splitting

Should be fairly trivial in comparison to merging.

  1. Upload a normal map in the web ui
  2. Extract map exchange string and create a gridworld based on that
  3. Prepopulate the gridworld using the uploaded map as a base. Delete all chunks outside of the normal grid square area.

A major challenge I forsee is figuring out how much of the map to pregenerate. I suppose just picking all squares with inserters, belts or rails should do pretty well. Another option is simply to ask for a number squared.

Load balancing and cluster performance

  • Automatically stop inactive servers
  • Manual migrations from web interface
  • Track approximate instance resource utilization
  • Automatic migrations depending on server laod

Todo list before 1.0 release

These are features I want working before 1.0 release:

  • One click gridworld creation
  • Gridworld minimap
  • - render entities on map
  • #14
  • Dynamically create servers as players move about
  • Show players on minimap
  • #13
  • #7

Crash on instance join via lobby

`16.644 Error MainLoop.cpp:1404: Exception at tick 21771: The scenario level caused a non-recoverable error.
Please report this error to the scenario author.

Error while running event level::on_player_joined_game (ID 45)
...on/building_restrictions/set_player_permission_group.lua:12: attempt to index local 'faction' (a nil value)
stack traceback:
...on/building_restrictions/set_player_permission_group.lua:12: in function 'set_player_permission_group'
modules/gridworld/gridworld.lua:90: in function 'handler'
core/lualib/event_handler.lua:47: in function <core/lualib/event_handler.lua:45>
16.644 Error ServerMultiplayerManager.cpp:92: MultiplayerManager failed: "The scenario level caused a non-recoverable error.
Please report this error to the scenario author.

Error while running event level::on_player_joined_game (ID 45)
...on/building_restrictions/set_player_permission_group.lua:12: attempt to index local 'faction' (a nil value)
stack traceback:
...on/building_restrictions/set_player_permission_group.lua:12: in function 'set_player_permission_group'
modules/gridworld/gridworld.lua:90: in function 'handler'
core/lualib/event_handler.lua:47: in function <core/lualib/event_handler.lua:45>"
16.644 Info ServerMultiplayerManager.cpp:814: updateTick(21771) changing state from(InGame) to(Failed)
16.659 Info NetworkInputListener.cpp:46: Refusing Input Action [0 65535 ServerCommand] because multiplayer control is not ready
16.659 Quitting: multiplayer error.
[error] Error handling ipc-inventory_sync_acquire:
Error: Connection closed
at EventEmitter.onEnd (/home/vm/clusterio/node_modules/rcon-client/lib/rcon.js:113:45)
at EventEmitter.emit (node:events:530:35)
at Socket. (/home/vm/clusterio/node_modules/rcon-client/lib/rcon.js:58:26)
at Socket.emit (node:events:518:28)
at TCP. (node:net:337:12)
16.949 Info ServerMultiplayerManager.cpp:154: Quitting multiplayer connection.
16.949 Info ServerMultiplayerManager.cpp:814: updateTick(4294967295) changing state from(Failed) to(Closed)
16.950 Info UDPSocket.cpp:233: Closing socket
16.950 Info UDPSocket.cpp:263: Socket closed
16.950 Info UDPSocket.cpp:233: Closing socket
17.110 Info UDPSocket.cpp:233: Closing socket
17.110 Info UDPSocket.cpp:263: Socket closed
17.113 Goodbye
[error] Factorio server unexpectedly shut down with code 255`

Optimize sending map data by using binary strings

Currently the colors for map data is sent as hexadecimal strings where 8 bytes are used to represent color: AABBCCDD for rgba. Lua and factorio supports putting binary data in strings using string.char(0-255) which allows us to compress it to 4 bytes.

For additional compression we could also take advantage of the actual color palette in use being far more restricted by finding all relevant map colors, transferring them to the controller once and then using a single byte to index the color. This would give us a nice and compact 1 byte per tile for dump_mapview.

Similar reductions can also be done to the position coordinates. Currently the position is sent as a string, but sending long decimal numbers as strings takes a lot of space. The position could be sent losslessly as 2x8 bytes or truncated as 2x4 bytes, bringing us to a worst case of 9 bytes per tile before compression.

Recombine instances into a single map

Button in the web interface should:

  1. Create a new instance
  2. Start each instance one by one and copy all entities, tiles and resources over to the newly created instance

Faction PVP/PVE system

  • Create and manage factions
  • Faction building permissions on servers
  • Fix broken server claiming logic
  • Faction combat (production required to maintain/defeat claims)

crash on gui click

After creating and switch to my own force I was able to join without crashing an instance.. I imagine this is the result but should have a nil check anyway possibly.

`766.830 Error MainLoop.cpp:1404: Exception at tick 45582: The scenario level caused a non-recoverable error.
Please report this error to the scenario author.

Error while running event level::on_gui_click (ID 1)
...les/gridworld/faction/gui/faction_server_status/draw.lua:11: attempt to index local 'player_faction' (a nil value)
stack traceback:
...les/gridworld/faction/gui/faction_server_status/draw.lua:11: in function 'draw'
modules/gridworld/gui/menu/events.lua:10: in function '?'
...urrently-playing/modules/gridworld/util/run_function.lua:3: in function 'run_function'
modules/gridworld/gui/events.lua:11: in function 'on_gui_click'
modules/gridworld/gridworld.lua:187: in function 'handler'
core/lualib/event_handler.lua:47: in function <core/lualib/event_handler.lua:45>
766.831 Error ServerMultiplayerManager.cpp:92: MultiplayerManager failed: "The scenario level caused a non-recoverable error.
Please report this error to the scenario author.

Error while running event level::on_gui_click (ID 1)
...les/gridworld/faction/gui/faction_server_status/draw.lua:11: attempt to index local 'player_faction' (a nil value)
stack traceback:
...les/gridworld/faction/gui/faction_server_status/draw.lua:11: in function 'draw'
modules/gridworld/gui/menu/events.lua:10: in function '?'
...urrently-playing/modules/gridworld/util/run_function.lua:3: in function 'run_function'
modules/gridworld/gui/events.lua:11: in function 'on_gui_click'
modules/gridworld/gridworld.lua:187: in function 'handler'
core/lualib/event_handler.lua:47: in function <core/lualib/event_handler.lua:45>"`

Connecting directly to an instance via direct connect causes an instance crash

Connecting directly to an instance via direct connect bypassing the lobby causes an instance crash.

`344.917 Error MainLoop.cpp:1404: Exception at tick 32075: The scenario level caused a non-recoverable error.
Please report this error to the scenario author.

Error while running event level::on_player_joined_game (ID 45)
...on/building_restrictions/set_player_permission_group.lua:12: attempt to index local 'faction' (a nil value)
stack traceback:
...on/building_restrictions/set_player_permission_group.lua:12: in function 'set_player_permission_group'
modules/gridworld/gridworld.lua:90: in function 'handler'
core/lualib/event_handler.lua:47: in function <core/lualib/event_handler.lua:45>
344.917 Error ServerMultiplayerManager.cpp:92: MultiplayerManager failed: "The scenario level caused a non-recoverable error.
Please report this error to the scenario author.

Error while running event level::on_player_joined_game (ID 45)
...on/building_restrictions/set_player_permission_group.lua:12: attempt to index local 'faction' (a nil value)
stack traceback:
...on/building_restrictions/set_player_permission_group.lua:12: in function 'set_player_permission_group'
modules/gridworld/gridworld.lua:90: in function 'handler'
core/lualib/event_handler.lua:47: in function <core/lualib/event_handler.lua:45>"
344.917 Info ServerMultiplayerManager.cpp:814: updateTick(32075) changing state from(InGame) to(Failed)
344.932 Info NetworkInputListener.cpp:46: Refusing Input Action [0 65535 ServerCommand] because multiplayer control is not ready
344.932 Quitting: multiplayer error.
[error] Error handling ipc-inventory_sync_acquire:
Error: Connection closed
at EventEmitter.onEnd (/home/vm/clusterio/node_modules/rcon-client/lib/rcon.js:113:45)
at EventEmitter.emit (node:events:530:35)
at Socket. (/home/vm/clusterio/node_modules/rcon-client/lib/rcon.js:58:26)
at Socket.emit (node:events:518:28)
at TCP. (node:net:337:12)
345.219 Info ServerMultiplayerManager.cpp:154: Quitting multiplayer connection.
345.220 Info ServerMultiplayerManager.cpp:814: updateTick(4294967295) changing state from(Failed) to(Closed)
345.221 Info UDPSocket.cpp:233: Closing socket
345.221 Info UDPSocket.cpp:263: Socket closed
345.221 Info UDPSocket.cpp:233: Closing socket
345.316 Info UDPSocket.cpp:233: Closing socket
345.316 Info UDPSocket.cpp:263: Socket closed
345.319 Goodbye
[error] Factorio server unexpectedly shut down with code 255`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.