commit 9aeb1882cf2bc2929fde337be33c78aca20fedf3
Author: Mikołaj Lenczewski <mblenczewski@gmail.com>
Date: Mon, 29 Apr 2024 16:46:36 +0000
Initial commit
Diffstat:
26 files changed, 222 insertions(+), 0 deletions(-)
diff --git a/.editorconfig b/.editorconfig
@@ -0,0 +1,26 @@
+root = true
+
+[*]
+end_of_line = lf
+charset = utf-8
+trim_trailing_whitespace = true
+insert_final_newline = true
+
+# visual studio editorconfig plugin specific settings
+guidelines = 80, 120, 160
+
+[*.{c,h}]
+indent_style = tab
+indent_size = 8
+
+[*.sh]
+indent_style = tab
+indent_size = 8
+
+[*.py]
+indent_style = space
+indent_size = 4
+
+[*.{conf,json,md,txt}]
+indent_style = space
+indent_size = 2
diff --git a/.gitignore b/.gitignore
@@ -0,0 +1 @@
+**/.*.swp
diff --git a/LICENSE b/LICENSE
@@ -0,0 +1,18 @@
+The MIT-Zero License
+
+Copyright (c) 2024 Mikołaj Lenczewski <mblenczewski@gmail.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/PROTOCOL b/PROTOCOL
@@ -0,0 +1,2 @@
+rcg
+==============================================================================
diff --git a/README b/README
@@ -0,0 +1,23 @@
+rcg: robot card game
+==============================================================================
+A simple card game, written for AI agents to play against themselves.
+
+rcg: Building
+------------------------------------------------------------------------------
+To build the server and all agents, simply run:
+```sh
+$ ./build.sh
+```
+
+To benchmark two agents against each other, use the `extras/benchmark.py`
+script, as follows:
+```sh
+$ ./extras/benchmark.py <agent1> <agent2> <iters>
+```
+
+To host a tournament, use the `extras/tournament.py` script as follows:
+```sh
+$ ./extras/tournament.py <schedule.txt> <output.txt>
+```
+
+For concrete documentation, please read the individual scripts.
diff --git a/agents/example_c_agent/.gitignore b/agents/example_c_agent/.gitignore
@@ -0,0 +1 @@
+bin/
diff --git a/agents/example_c_agent/agent.c b/agents/example_c_agent/agent.c
@@ -0,0 +1,10 @@
+#include "protocol.h"
+
+int
+main(int argc, char **argv)
+{
+ (void) argc;
+ (void) argv;
+
+ return 0;
+}
diff --git a/agents/example_c_agent/build.sh b/agents/example_c_agent/build.sh
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+CC="${CC:-cc}"
+
+WARNINGS="-Wall -Wextra -Wpedantic -Werror"
+
+CFLAGS="-std=c11 -Og -g"
+CPPFLAGS="-I../../common"
+
+set -ex
+
+mkdir -p bin
+
+$CC -o bin/robocg agent.c $WARNINGS $CFLAGS $CPPFLAGS
diff --git a/agents/example_c_agent/clean.sh b/agents/example_c_agent/clean.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+set -ex
+
+rm -rf bin
diff --git a/agents/example_c_agent/run.sh b/agents/example_c_agent/run.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+exec $(dirname $0)/bin/agent $@
diff --git a/agents/robocg/.gitignore b/agents/robocg/.gitignore
@@ -0,0 +1 @@
+bin/
diff --git a/agents/robocg/build.sh b/agents/robocg/build.sh
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+CC="${CC:-cc}"
+
+WARNINGS="-Wall -Wextra -Wpedantic -Werror"
+
+CFLAGS="-std=c11 -Og -g"
+CPPFLAGS="-I../../common"
+
+set -ex
+
+mkdir -p bin
+
+$CC -o bin/agent robocg/robocg.c $WARNINGS $CFLAGS $CPPFLAGS
diff --git a/agents/robocg/clean.sh b/agents/robocg/clean.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+set -ex
+
+rm -rf bin
diff --git a/agents/robocg/robocg/robocg.c b/agents/robocg/robocg/robocg.c
@@ -0,0 +1,10 @@
+#include "robocg.h"
+
+int
+main(int argc, char **argv)
+{
+ (void) argc;
+ (void) argv;
+
+ return 0;
+}
diff --git a/agents/robocg/robocg/robocg.h b/agents/robocg/robocg/robocg.h
@@ -0,0 +1,6 @@
+#ifndef ROBOCG_H
+#define ROBOCG_H
+
+#include "protocol.h"
+
+#endif /* ROBOCG_H */
diff --git a/agents/robocg/run.sh b/agents/robocg/run.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+exec $(dirname $0)/bin/agent $@
diff --git a/build.sh b/build.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+cd server
+
+./build.sh
+
+cd ..
+
+for dir in agents/*; do
+ cd $dir
+
+ ./build.sh
+
+ cd ../..
+done
diff --git a/clean.sh b/clean.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+cd server
+
+./clean.sh
+
+cd ..
+
+for dir in agents/*; do
+ cd $dir
+
+ ./clean.sh
+
+ cd ../..
+done
diff --git a/common/protocol.h b/common/protocol.h
@@ -0,0 +1,4 @@
+#ifndef PROTOCOL_H
+#define PROTOCOL_H
+
+#endif /* PROTOCOL_H */
diff --git a/extra/benchmark.py b/extra/benchmark.py
@@ -0,0 +1,5 @@
+#!/usr/bin/env python3
+
+if __name__ == '__main__':
+ print('Hello, World!')
+
diff --git a/extra/tournament.py b/extra/tournament.py
@@ -0,0 +1,5 @@
+#!/usr/bin/env python3
+
+if __name__ == '__main__':
+ print('Hello, World!')
+
diff --git a/server/.gitignore b/server/.gitignore
@@ -0,0 +1 @@
+bin/
diff --git a/server/build.sh b/server/build.sh
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+CC="${CC:-cc}"
+
+WARNINGS="-Wall -Wextra -Wpedantic -Werror"
+
+CFLAGS="-std=c11 -Og -g"
+CPPFLAGS="-I../common"
+
+set -ex
+
+mkdir -p bin
+
+$CC -o bin/server server/server.c $WARNINGS $CFLAGS $CPPFLAGS
diff --git a/server/clean.sh b/server/clean.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+set -ex
+
+rm -rf bin
diff --git a/server/server/server.c b/server/server/server.c
@@ -0,0 +1,10 @@
+#include "server.h"
+
+int
+main(int argc, char **argv)
+{
+ (void) argc;
+ (void) argv;
+
+ return 0;
+}
diff --git a/server/server/server.h b/server/server/server.h
@@ -0,0 +1,6 @@
+#ifndef SERVER_H
+#define SERVER_H
+
+#include "protocol.h"
+
+#endif /* SERVER_H */