Skip to content
Snippets Groups Projects
Commit c274d542 authored by Peter Gerwinski's avatar Peter Gerwinski
Browse files

Redcode-Beispiele und Turnier-Software, 3.5.2023

parent ad265685
No related branches found
No related tags found
No related merge requests found
;redcode
;name Antiknirps
;author Peter Gerwinski
;strategy Modifiziere den Code von Knirps, um ihn zu stoppen
;assert 1
falle DAT #0
DAT #0
start DJN start, falle
JMP start
END start
;redcode
;name Dwarf
;author A. K. Dewdney, modified by Peter Gerwinski
;assert 1
bomb DAT #3
dwarf ADD #1, bomb
MOV bomb, @bomb
JMP dwarf
END dwarf ; Programs start at the first line unless
; an "END start" pseudo-op appears to indicate
; the first logical instruction. Also, nothing
; after the END instruction will be assembled.
;redcode
;name Dwarf
;author A. K. Dewdney, modified by Peter Gerwinski
;assert 1
bomb DAT #0
dwarf ADD #-1, bomb
MOV bomb, @bomb
JMP dwarf
END dwarf ; Programs start at the first line unless
; an "END start" pseudo-op appears to indicate
; the first logical instruction. Also, nothing
; after the END instruction will be assembled.
;name Koschka
;version 0.6, 2022-05-10
;author Peter Gerwinski
;assert 1
num dat #-2
trap spl 0
start mov trap, <pos1
jmn start, pos1
fini mov num, <pos2
jmp fini
pos2 dat #-2
pos1 dat #num
end start
;name Mice
;author Chip Wendell
;assert 1
ptr dat #0
start mov #12, ptr ; n = 12
loop mov @ptr, <dest ; *dest = *(ptr+(*ptr))
djn loop, ptr ; if(--ptr != 0)
; goto loop
spl @dest ; split(*dest)
add #653, dest ; dest += 653
jmp start ; goto start
dest dat #833
end start
;name Mice
;author Chip Wendell
;assert 1
0 ptr dat #0
1 start mov #12, ptr
2 loop mov @ptr, <dest ; kopiere das, worauf ptr zeigt, nach dest,
3 djn loop, ptr ; ziehe aber vorher von dest 1 ab
4 spl @dest ; djn zieht von ptr 1 ab, springt danach nach loop
5 add #653, dest
6 jmz start, ptr ; ptr nicht 0 --> etwas schiefgegangen --> Abbruch
7 dest dat #833
8 dat #0 ; außerhalb des Programms, initialisiert auf dat #0
9 dat #0 end start ; bedeutet: Fange in Zeile "start" an.
10 dat #0
11 dat #0
12 dat #0
13
...
...
825
826
827 ptr dat #0
828 start mov #12, ptr ; Hierhin zeigt dest nach dem Kopieren.
829 loop mov @ptr, <dest
830 djn loop, ptr
831 spl @dest
832 add #653, dest
833 jmz start, ptr
834 dest dat #833 ; ptr = 6
835 dat #0
836 dat #0
837 dat #0
838 dat #0
839 dat #0 ; Hier landet die Kopie: dest(7) + 833 - 1
840
841
842
...
No preview for this file type
......@@ -329,7 +329,6 @@
\phantom{Problem: }bringt "`Dwarf"' sich selbst zum Absturz.\\[\smallskipamount]
\pause
Lösung: \textcolor{red}{Haben Sie Ideen?}
\pause
\textcolor{red}{\textarrow\ Übungsaufgabe}
\end{frame}
......@@ -404,6 +403,8 @@
\end{frame}
\iffalse
\begin{frame}[fragile]
\showsubsection
......@@ -460,6 +461,8 @@
\end{frame}
\fi
\begin{frame}[fragile]
\showsubsection
......
#!/bin/bash
echo "score wins draws"
for x in *.score; do
printf "%4d %4d %4d %-15s\n" \
$(wc -c "$x" | sed -e 's/ .*$//') \
$(( $(grep -o "\*" "$x" | wc -l) / 3 )) \
$(grep -o "+" "$x" | wc -l) \
$(basename $x .red.score)
done \
| sort -rn
#!/bin/bash
if [ "$1" = "-s" ]; then
core_size="$2"
shift 2
fi
if [ -n "$1" ]; then
PARTICIPANTS="$@"
else
PARTICIPANTS=$(ls *.red)
fi
#PARTICIPANTS="nothing.red knirps.red mice.red $1"
PMARS="$HOME/bo/2012ws/rtech/material/pmars-0.9.2/src/pmars-ncurses"
mars ()
{
c1=$2
c2=$3
if [ -n "$core_size" ]; then
set $($PMARS -8 -b -k -p 64 -s $core_size $2 $3)
else
set $($PMARS -8 -b -k -p 64 -s $1 $2 $3)
fi
if [ $1 = 1 ]; then
echo -n "***" >> $c1.score
touch $c2.score
elif [ $3 = 1 ]; then
touch $c1.score
echo -n "***" >> $c2.score
else
echo -n "+" >> $c1.score
echo -n "+" >> $c2.score
fi
}
rm -f *.score
./turn $PARTICIPANTS \
| sort -R \
| tee tournament.log \
| while read line; do
$line
done
./scores
#include <stdio.h>
#include <stdlib.h>
int main (int argc, char **argv)
{
srand (42);
for (char **p = argv + 1; *p; p++)
for (char **q = p + 1; *q; q++)
for (int i = 0; i < 100; i++)
printf ("mars %d %s %s\n",
512 + rand () % (8192 - 512 + 1), *p, *q);
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment