<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to README</title><link>https://sourceforge.net/p/pybotwar/wiki/README/</link><description>Recent changes to README</description><atom:link href="https://sourceforge.net/p/pybotwar/wiki/README/feed" rel="self"/><language>en</language><lastBuildDate>Sat, 18 Mar 2023 13:40:53 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/pybotwar/wiki/README/feed" rel="self" type="application/rss+xml"/><item><title>README modified by Lee Harr</title><link>https://sourceforge.net/p/pybotwar/wiki/README/</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;pybotwar is a fun and educational game where players&lt;br/&gt;
write computer programs to control simulated robots.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://sourceforge.net/p/pybotwar/"&gt;https://sourceforge.net/p/pybotwar/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;INTRODUCTION&lt;/p&gt;
&lt;p&gt;Your task is to create a computer program to control a&lt;br/&gt;
robot for the arena. The last robot alive is the winner.&lt;/p&gt;
&lt;p&gt;Robot programs run in separate processes from the main&lt;br/&gt;
simulation, and communicate with the main program over&lt;br/&gt;
standard input and standard output channels. Theoretically,&lt;br/&gt;
this means that the robots could be limited in the amount&lt;br/&gt;
of system access they have, and how much of the system's&lt;br/&gt;
resources they can consume.&lt;/p&gt;
&lt;p&gt;CAUTION!&lt;br/&gt;
Right now, that is not the case. Robot programs run&lt;br/&gt;
as regular Python programs, using the regular Python&lt;br/&gt;
interpreter, and can do anything any other program&lt;br/&gt;
can do.&lt;/p&gt;
&lt;p&gt;In the future, I intend to implement some kind of&lt;br/&gt;
sandboxing for robot programs, but that is not done.&lt;/p&gt;
&lt;p&gt;As long as you wrote the program yourself, using the&lt;br/&gt;
standard Pybotwar API, it should not be a problem, but&lt;br/&gt;
do not run robot programs written by other people&lt;br/&gt;
without thorough consideration.&lt;/p&gt;
&lt;p&gt;INSTALLATION&lt;/p&gt;
&lt;p&gt;Make sure the required dependencies are installed.&lt;/p&gt;
&lt;p&gt;pybotwar uses pybox2d for the physical simulation,&lt;br/&gt;
and uses either pyqt or pygame and pygsear for the&lt;br/&gt;
visualization.&lt;/p&gt;
&lt;p&gt;Unpack the pybotwar archive and run the program&lt;br/&gt;
from the unpacked folder. No installation is needed,&lt;br/&gt;
but you may need to change the configuration. See&lt;br/&gt;
CONFIGURATION for details.&lt;/p&gt;
&lt;p&gt;DEPENDENCIES&lt;/p&gt;
&lt;p&gt;python3:&lt;br/&gt;
&lt;a href="http://python.org/" rel="nofollow"&gt;http://python.org/&lt;/a&gt;&lt;br/&gt;
        (tested with python-3.6.7)&lt;/p&gt;
&lt;p&gt;box2d-py:&lt;br/&gt;
&lt;a href="http://pybox2d.googlecode.com/" rel="nofollow"&gt;http://pybox2d.googlecode.com/&lt;/a&gt;&lt;br/&gt;
        (tested with pybox2d-2.3.8)&lt;br/&gt;
        (pip3 install box2d-py)&lt;/p&gt;
&lt;p&gt;pyqt5 (optional, but strongly recommended):&lt;br/&gt;
&lt;a href="http://www.riverbankcomputing.co.uk/software/pyqt/" rel="nofollow"&gt;http://www.riverbankcomputing.co.uk/software/pyqt/&lt;/a&gt;&lt;br/&gt;
        (tested with python3-pyqt5-5.10.1)&lt;/p&gt;
&lt;p&gt;qtsvg5 (optional -- required if using pyqt5):&lt;br/&gt;
&lt;a href="http://pyqt.sourceforge.net/Docs/PyQt5/QtSvg.html" rel="nofollow"&gt;http://pyqt.sourceforge.net/Docs/PyQt5/QtSvg.html&lt;/a&gt;&lt;br/&gt;
        (tested with python3-pyqt5.qtsvg-5.10.1)&lt;/p&gt;
&lt;p&gt;pygame (optional):&lt;br/&gt;
&lt;a href="http://pygame.org/" rel="nofollow"&gt;http://pygame.org/&lt;/a&gt;&lt;br/&gt;
        (tested with pygame-1.9.1)&lt;/p&gt;
&lt;p&gt;pygsear (optional -- required if using pygame):&lt;br/&gt;
&lt;a href="http://www.nongnu.org/pygsear/" rel="nofollow"&gt;http://www.nongnu.org/pygsear/&lt;/a&gt;&lt;br/&gt;
        (tested with pygsear-0.53.2)&lt;/p&gt;
&lt;p&gt;RUNNING&lt;/p&gt;
&lt;p&gt;Run the program:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;./pybotwar
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;If running from the development environment&lt;br/&gt;
    (ie. from a cloned mercurial repo)&lt;br/&gt;
    use the development flag:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;./pybotwar -d
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Use the -h option for additional help:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;./pybotwar -d -h
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;|usage: main.py &lt;span&gt;[-h]&lt;/span&gt; &lt;span&gt;[-T]&lt;/span&gt; &lt;span&gt;[-n NAME]&lt;/span&gt; &lt;span&gt;[-A]&lt;/span&gt; &lt;span&gt;[-b NBATTLES]&lt;/span&gt;&lt;br/&gt;
|               &lt;span&gt;[--robots ROBOT [ROBOT ...]&lt;/span&gt;] &lt;span&gt;[--lineup LNAME]&lt;/span&gt;&lt;br/&gt;
|               &lt;span&gt;[--supertournament]&lt;/span&gt; &lt;span&gt;[--supertournament-continue]&lt;/span&gt; &lt;span&gt;[-10]&lt;/span&gt;&lt;br/&gt;
|               &lt;span&gt;[--tournaments [N]&lt;/span&gt;] &lt;span&gt;[--results TNAME|TDATETIME]&lt;/span&gt; &lt;span&gt;[-g]&lt;/span&gt; &lt;span&gt;[-u]&lt;/span&gt; &lt;span&gt;[-U]&lt;/span&gt;&lt;br/&gt;
|               &lt;span&gt;[-Q]&lt;/span&gt; &lt;span&gt;[-P]&lt;/span&gt; &lt;span&gt;[-D]&lt;/span&gt; &lt;span&gt;[-S]&lt;/span&gt; &lt;span&gt;[-B]&lt;/span&gt;&lt;br/&gt;
|&lt;br/&gt;
|optional arguments:&lt;br/&gt;
|  -h, --help            show this help message and exit&lt;br/&gt;
|  -T, --testmode        run in test mode (All robots log. No cleanup on exit.)&lt;br/&gt;
|  -n NAME, --tournament-name NAME&lt;br/&gt;
|                        tournament name (default=&amp;lt;datetime&amp;gt;)&lt;br/&gt;
|  -A, --add-to-tournament&lt;br/&gt;
|                        if tournament named in -n already exists, continue it.&lt;br/&gt;
|  -b NBATTLES, --battles NBATTLES&lt;br/&gt;
|                        number of battles in tournament (default=1)&lt;br/&gt;
|  --robots ROBOT &lt;span&gt;[ROBOT ...]&lt;/span&gt;&lt;br/&gt;
|                        list of robots to load&lt;br/&gt;
|  --lineup LNAME        load robots from lineup file&lt;br/&gt;
|  --supertournament     run a supertournament (all possible combinations of&lt;br/&gt;
|                        robots play in tournaments with the same name,&lt;br/&gt;
|                        combining all stats.)&lt;br/&gt;
|  --supertournament-continue&lt;br/&gt;
|                        internal use only.&lt;br/&gt;
|  -10, --top-10         show top 10 robot stats (implies -g)&lt;br/&gt;
|  --tournaments &lt;span&gt;[N]&lt;/span&gt;     list N most recent tournaments and exit (default=5)&lt;br/&gt;
|  --results TNAME|TDATETIME&lt;br/&gt;
|                        show results for tournament TNAME or at TDATETIME&lt;br/&gt;
|  -g, --no-graphics     non graphics mode&lt;br/&gt;
|  -u, --quiet           reduce output&lt;br/&gt;
|  -U, --very-quiet      no output&lt;br/&gt;
|  -Q, --pyqt-graphics   enable PyQt interface&lt;br/&gt;
|  -P, --pygsear-graphics&lt;br/&gt;
|                        enable Pygame (and Pygsear) interface&lt;br/&gt;
|  -D, --upgrade-db      upgrade database (WARNING! Deletes database!)&lt;br/&gt;
|  -S, --reset-qt-settings&lt;br/&gt;
|                        reset Qt settings&lt;br/&gt;
|  -B, --app-debug       enable app debug log&amp;lt;/datetime&amp;gt;&lt;/p&gt;
&lt;p&gt;CONFIGURATION&lt;/p&gt;
&lt;p&gt;The first time you run pybotwar it will create an empty&lt;br/&gt;
configuration file called conf.py&lt;/p&gt;
&lt;p&gt;Look in defaults.py to see the values which can be changed.&lt;/p&gt;
&lt;p&gt;IMPORTANT NOTE!&lt;br/&gt;
Windows users especially will need to change the value for&lt;br/&gt;
subproc_python or the program will not run.&lt;/p&gt;
&lt;p&gt;Add a line to conf.py like ...&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;subproc_python = 'C:/Full/Path/To/Python36.exe'
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Also note that it is not necessary for the user to have write&lt;br/&gt;
access to the program directory to use the game, but the conf.py&lt;br/&gt;
file must be created first. If using the PyQt interface, all&lt;br/&gt;
users will have their own settings file and conf.py will not&lt;br/&gt;
be used, but the file must be present.&lt;/p&gt;
&lt;p&gt;CREATING NEW ROBOTS&lt;/p&gt;
&lt;p&gt;Copy the template.py file to a new file in the robots&lt;br/&gt;
folder, for example 'mynewrobot.py'&lt;/p&gt;
&lt;p&gt;In your new module, add initialization code to the .initialize()&lt;br/&gt;
method if needed, or you can delete the method.&lt;/p&gt;
&lt;p&gt;The .initialize() method is called once, immediately after the&lt;br/&gt;
robot is created, and must return in less than a second or&lt;br/&gt;
the robot will be placed in an error state and removed from&lt;br/&gt;
the battle.&lt;/p&gt;
&lt;p&gt;Add code to generate your robot's response to the .respond()&lt;br/&gt;
method.&lt;/p&gt;
&lt;p&gt;The .respond() method will be called 60 times per second as&lt;br/&gt;
the battle continues and it must return in less than 0.015&lt;br/&gt;
seconds or the robot will be placed in an error state and&lt;br/&gt;
removed from the battle.&lt;/p&gt;
&lt;p&gt;See the robot.Robot class for useful methods to set the&lt;br/&gt;
response, or the example robots for hints on how to use&lt;br/&gt;
those methods.&lt;/p&gt;
&lt;p&gt;For more information, see the pybotwar wiki:&lt;br/&gt;
&lt;a href="https://sourceforge.net/p/pybotwar/wiki/"&gt;https://sourceforge.net/p/pybotwar/wiki/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;STARTING A BATTLE&lt;/p&gt;
&lt;p&gt;To use your new robot in a battle, choose Battle -&amp;gt; New Battle.&lt;br/&gt;
Select your robot on the left and click "Add," then either&lt;br/&gt;
save the robot lineup for future use or click "Start Battle."&lt;/p&gt;
&lt;p&gt;To use your robot in pygame or text mode, you can specify the names&lt;br/&gt;
of the robots for the battle from the command line:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;./pybotwar -d -g --robots myrobot1 anotherrobot robot05
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;You can also use the older method and modify conf.py directly.&lt;br/&gt;
Add a line to conf.py with the name of your new module:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;mine = 'mynewrobot'
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Add your module reference to the robots list:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;robots.append(mine)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Or, if you only want to test your own robot:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;robots&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;mine&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;You can also run with multiple copies of the same robot:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;# Three copies of example robot 1 and three of my new robot
robots = [r1, r1, r1, mine, mine, mine]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;If you want to run with only your new robot, be sure to&lt;br/&gt;
run in test mode, or the battle will be over before it&lt;br/&gt;
begins:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;./pybotwar -d -T
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;TOURNAMENTS&lt;/p&gt;
&lt;p&gt;At the start of each battle, the robots are always placed in&lt;br/&gt;
the arena at random locations and with random orientations.&lt;br/&gt;
Also, many robots use random numbers to determine which way&lt;br/&gt;
to go and when to perform their actions. Therefore, each time&lt;br/&gt;
the same set of robots are placed in the arena, the results&lt;br/&gt;
may be different.&lt;/p&gt;
&lt;p&gt;To determine which robots are truly the strongest, run a&lt;br/&gt;
tournament. A tournament is a series of battles run with the&lt;br/&gt;
same set of robots. Statistics will be kept during the series&lt;br/&gt;
and reported when the series is complete.&lt;/p&gt;
&lt;p&gt;SUPERTOURNAMENTS&lt;/p&gt;
&lt;p&gt;A supertournament is a series of tournaments where the participating&lt;br/&gt;
robots are matched up in all possible combinations. For instance,&lt;br/&gt;
a 5-game supertournament with robots r1, r2, and r3 would run a&lt;br/&gt;
series of 5-game tournaments like this:&lt;/p&gt;
&lt;p&gt;r1 vs r2 (5 battles)&lt;br/&gt;
r1 vs r3 (5 battles)&lt;br/&gt;
r2 vs r3 (5 battles)&lt;br/&gt;
r1 vs r2 vs r3 (5 battles)&lt;/p&gt;
&lt;p&gt;This will result in a total of 20 battles. This can take a long&lt;br/&gt;
time, so you may want to run supertournaments either in text mode,&lt;br/&gt;
or run them in the background.&lt;/p&gt;
&lt;p&gt;All of the statistics from all of the tournaments are combined in&lt;br/&gt;
to one report at the end of the supertournament.&lt;/p&gt;
&lt;p&gt;Some robots do well at surviving, but not so good at taking other&lt;br/&gt;
robots out of the game. Some do well early on, but have trouble&lt;br/&gt;
finishing off the last opponent.&lt;/p&gt;
&lt;p&gt;To really get a good idea of which are the strongest robots, run&lt;br/&gt;
a supertournament instead of a plain tournament.&lt;/p&gt;
&lt;p&gt;HISTORY&lt;/p&gt;
&lt;p&gt;pybotwar was inspired by the game RobotWar that existed&lt;br/&gt;
for the Apple ][ in the early 1980s. However, the method&lt;br/&gt;
of coding is more akin to the style of programs used&lt;br/&gt;
for the FIRST robotics competition, where a particular&lt;br/&gt;
user-defined method is called repeatedly (60 times&lt;br/&gt;
per second in this case) and must finish in a set&lt;br/&gt;
amount of time to avoid putting the robot in to an&lt;br/&gt;
error state and disabling it.&lt;/p&gt;
&lt;p&gt;RobotWar:&lt;br/&gt;
&lt;a href="http://en.wikipedia.org/wiki/RobotWar" rel="nofollow"&gt;http://en.wikipedia.org/wiki/RobotWar&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;FIRST Robotics Competition:&lt;br/&gt;
&lt;a href="http://en.wikipedia.org/wiki/FIRST_Robotics" rel="nofollow"&gt;http://en.wikipedia.org/wiki/FIRST_Robotics&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Lee Harr</dc:creator><pubDate>Sat, 18 Mar 2023 13:40:53 -0000</pubDate><guid>https://sourceforge.net3e5b6df1f799a9a6e519208d6fe1ca970d549ab2</guid></item></channel></rss>