Skip to content

Commit e826dd4

Browse files
committed
deploy: 628f935
1 parent 1c5fd2d commit e826dd4

33 files changed

+1021
-192
lines changed

.doctrees/bots/index.doctree

28 Bytes
Binary file not shown.
15 KB
Binary file not shown.

.doctrees/bots/setup.doctree

485 Bytes
Binary file not shown.

.doctrees/concepts/index.doctree

29 Bytes
Binary file not shown.
11.2 KB
Binary file not shown.

.doctrees/environment.pickle

5.64 KB
Binary file not shown.

_sources/bots/index.rst.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ Specifically, bots cannot cheat - no more than a regular player could.
88

99
.. toctree::
1010
setup
11+
programOverview
1112
troubleshooting
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
Program Overview
2+
================
3+
High-level look at basic bot program.
4+
5+
Environment Variables
6+
---------------------
7+
Some variables that may alter the behavior of your bot program.
8+
9+
- ``UNNATURAL_ROOT`` - path to the ``bin`` folder that contains the shared library.
10+
- ``UNNATURAL_CONNECT_LOBBY`` - id of Steam lobby to connect to.
11+
- ``UNNATURAL_CONNECT_ADDR`` - IP address or domain name to connect to.
12+
- ``UNNATURAL_CONNECT_PORT`` - port of the game server to connect to.
13+
14+
Program Lifecycle
15+
-----------------
16+
At start, you are in full control of the program.
17+
18+
Initialization
19+
^^^^^^^^^^^^^^
20+
21+
- You need to change current working directory to the ``bin`` directory in the game installation.
22+
Without it, the game will be unable to load maps and assets, even if it might load the shared library.
23+
24+
.. warning::
25+
Do *not* change current working directory once configured.
26+
27+
- Next you load the shared library.
28+
29+
.. tab-set::
30+
31+
.. tab-item:: Python
32+
:sync: python
33+
34+
TODO
35+
36+
.. tab-item:: C#
37+
:sync: csharp
38+
39+
The library is automatically loaded when you first access the global ``Game`` object.
40+
This happens inside the ``Bot`` constructor.
41+
42+
- Setup all your callbacks now.
43+
You may also set some parameters for the connection.
44+
45+
Connect
46+
^^^^^^^
47+
There are multiple ways to connect to a server.
48+
The usual approach is to first try reconnecting, in case the game has crashed previously.
49+
Second, you connect to an existing server using the parameters provided in the environment variables, if any.
50+
Third, you spin up your own server.
51+
52+
Alternatively, you may implement your own logic to determine how to connect to a server.
53+
54+
No matter the method, the game will now take control over the program.
55+
Your program is blocked until the network connection closes.
56+
All your further actions will happen inside callbacks only.
57+
58+
Game Loop
59+
^^^^^^^^^
60+
All your registered callbacks are now called, when appropriate.
61+
Notably, the ``Update`` callback is periodically called, no matter the game state.
62+
This is where you keep track of the state of the game, and perform any of your actions.
63+
64+
.. warning::
65+
The ``Update`` callback, and some other, may be called before the game has actually started (eg. in ``Session``), or when the map is not yet ``Loaded``.
66+
Be mindful of what operations are valid in these circumstances.
67+
68+
You may prematurely close the connection with the ``Disconnect`` function.
69+
This will do a graceful closing of the connection, that is, you will get some additional callbacks called.
70+
After that the connect function will return.
71+
72+
Finalization
73+
^^^^^^^^^^^^
74+
When the connection function returns, the network connection has already been closed, and you take back control over the program.
75+
You may do any cleanup operations, for example you may save some statistics from the game.
76+
Ultimately, you should unload the shared library, and exit the program.
77+
78+
It may be tempting to just loop and connect again to next server, however this is strongly discouraged.

_sources/bots/setup.rst.txt

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
Setup
2-
====
2+
=====
33
You can write your bot in any language, as long as it can load a dynamic/shared library (.dll/.so).
44
The shared library is distributed together with the game.
55

66
The uwapi repository contains c/c++ headers for all functions and structures provided by the library.
7-
Furthermore, it contains convenient wrappers for Python and for C# for quicker start.
7+
Furthermore, it contains convenient wrappers for Python and C# for easy start.
88

99
.. important::
1010
Copy ``steam_appid.txt`` into the ``bin`` folder.
@@ -17,6 +17,16 @@ You will find the ``steam_appid.txt`` in the uwapi repository.
1717
Copy it into the ``bin`` folder, next to the game executable.
1818

1919
.. important::
20-
If your Steam games are in non-default location, define environment variable ``UNNATURAL_ROOT`` to the directory containing the library.
20+
If you installed Unnatural World in non-default location, define environment variable ``UNNATURAL_ROOT`` to the directory containing the library.
2121

22-
The default path on Windows: ``C:\Program Files (x86)\Steam\steamapps\common\Unnatural Worlds\bin``, on linux: ``~/.steam/steam/steamapps/common/Unnatural Worlds/bin``.
22+
.. tab-set::
23+
24+
.. tab-item:: Windows
25+
:sync: windows
26+
27+
Default path: ``C:\Program Files (x86)\Steam\steamapps\common\Unnatural Worlds\bin``
28+
29+
.. tab-item:: Linux
30+
:sync: linux
31+
32+
Default path: ``~/.steam/steam/steamapps/common/Unnatural Worlds/bin``

_sources/concepts/index.rst.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ Glossary and explanation of concepts used throughout this documentation and in t
66
map
77
prototypes
88
ecs
9+
programState

0 commit comments

Comments
 (0)