Back to ToR Home

The Trade or Raid BASIC Program (Version 7)

This is the complete BASIC code used for our tournament
To see only the 26 individuel strategies and read some comments, go to strategies

You may copy and paste the code into a text editor and save it as a text file, then open it with your BASIC software.
Feel free to try it out, but do not forget to mention the source (this website) if you decide to use it <in public>.

This is just some code produced quickly to serve as a frame to fit in the 26 strategies.
You might want to convert it into a PASCAL program and improve the software.
Just go ahead, but please send us a the code (= a text file) for this website.


REM ToR Version 7 - Trade or Raid - an iPD computer simulation
REM Made at Wolfgang-Borchert-School, Beisinger Weg 80, 45657 Recklinghausen, Germany
REM See website:  www.wobo4u.de
REM Or go directly to:  www.wobo4u.de/ToR/ToRhome.html

REM SCREEN 0: WIDTH 80, 43
RANDOMIZE

REM integer variables: nom, moves, met, n, b, k
REM integer variables: lepl, ripl, mynum, otnum, moni
REM string variables: side$ ="l" or "r", choice$, myname$, otname$, iam$
REM string variables: myrecord$, otrecord$, mylast$, otlast$, myfirst$, otfirst$
DIM letter$(26): REM letter a-z = short name
DIM tor(26): REM Counts how often they traded or raided
DIM name$(26): REM name$(n) = full name possible
DIM descr$(26): REM descr$(n) describes the strategy in a few words
FOR n = 1 TO 26: letter$(n) = CHR$(n + 96): name$(n) = letter$(n): NEXT n
DIM money(26): DIM moneyfrom(26, 26): REM total money and money from meeting a particular partner
DIM record$(26, 26): REM who did what to whom. Lists letters d and c

again:
waiting = 0: moni = 0
CLS
PRINT "TRADE or RAID           will start soon."
PRINT : PRINT "To quit the simulation, press <q>.": PRINT "Please enter some information first."
LOCATE 7: PRINT "How many moves (5-15. Default:13) all together"; : INPUT moves
IF (moves < 5 OR moves > 15) AND NOT moves = 0 THEN GOTO again
IF moves = 0 THEN moves = 13
PRINT "  Okay,"; moves; "moves. But you will always meet twice on a yourney (move)."
PRINT "So there will be"; moves * 2; "meetings with each of your 25 partners."
PRINT "All together you will have to choose"; moves * 50; "times what to do."
PRINT : PRINT "You can tell the programme to show you the last move in detail."
PRINT "You will be able to see all important information about your 25 partners."
PRINT "If you want that, can you tell us who you are (= Enter letter a-z) "; : INPUT iam$
IF iam$ = "" THEN PRINT "  Okay, we will skip that.": GOTO quick
iam$ = LEFT$(iam$, 1): iam$ = LCASE$(iam$): moni = ASC(iam$) - 96
IF moni < 1 OR moni > 26 THEN GOTO again
PRINT "  Okay, your letter is <"; iam$; "> and your number is"; moni; "."
PRINT : PRINT "How many seconds do you want to view your moves "; : INPUT waiting
IF waiting > 0 THEN PRINT "  Okay, the programme will pause each time for"; waiting; "seconds."
IF waiting = 0 THEN PRINT "  Okay, no automatic delay. You will have to strike a key to go on."
quick:
LOCATE 21: PRINT "Ready!"
PRINT "Strike <s> to start the simulation.  Strike <n> to start again."
PRINT "Strike <q> to quit early!"
loopalot:
a$ = INKEY$
IF a$ = "n" THEN GOTO again
IF a$ = "q" THEN STOP
IF a$ <> "s" THEN GOTO loopalot
CLS

FOR nom = 1 TO moves
FOR lepl = 1 TO 26
FOR ripl = 1 TO 26
IF lepl = ripl THEN GOTO newdice
CLS : PRINT "Move number "; nom; "   "; letter$(lepl); " is meeting "; letter$(ripl),

side$ = "l"
changeside:
SELECT CASE side$
CASE "l"
mynum = lepl: otnum = ripl
CASE "r"
mynum = ripl: otnum = lepl
END SELECT

mymon = money(mynum): otmon = money(otnum)
myname$ = CHR$(mynum + 96): otname$ = CHR$(otnum + 96)
mymonfrom = moneyfrom(mynum, otnum): otmonfrom = moneyfrom(otnum, mynum)
myrecord$ = record$(mynum, otnum): otrecord$ = record$(otnum, mynum)
mylast$ = RIGHT$(myrecord$, 1): otlast$ = RIGHT$(otrecord$, 1)
myfirst$ = LEFT$(myrecord$, 1): otfirst$ = LEFT$(otrecord$, 1)
met = LEN(record$(mynum, otnum))

IF side$ = "r" THEN GOTO dontshow
PRINT "They have already met "; met; " times."
PRINT
PRINT myname$; " owns "; mymon, "and got "; mymonfrom; " from trade or raid with "; otname$
PRINT otname$; " owns "; otmon, "and got "; otmonfrom; " from trade or raid with "; myname$
PRINT myname$; " did this: "; myrecord$
PRINT otname$; " did this: "; otrecord$
dontshow:

REM ............. students have to fit in their code below ......

choice$ = "c"
SELECT CASE mynum

CASE 1
name$(1) = "Anny"
descr$(1) = "Killswitch 1"
IF RND < .6 THEN choice$ = "d" ELSE choice$ = "c"

CASE 2
name$(2) = "Bambi"
descr$(2) = "always defect"
IF RND > .2 THEN choice$ = "d" ELSE choice$ = "c"

CASE 3
name$(3) = "Spaniard"
descr$(3) = "Big Boat"
IF nom = 10 THEN choice$ = "d"
IF INSTR(otrecord$, "dcd") THEN choice$ = "d"
IF INSTR(otrecord$, "dd") THEN choice$ = "d"

CASE 4
name$(4) = "chrissi"
descr$(4) = "Tit for Tat"
IF otlast$ = "d" THEN choice$ = "d"

CASE 5
name$(5) = "Chris"
descr$(5) = "Fair play"
IF INSTR(otrecord$, "dd") THEN choice$ = "d"
IF mymon < otmon THEN choice$ = "d"

CASE 6
name$(6) = "Lars"
descr$(6) = "Cheaty"
IF otlast$ = "d" THEN choice$ = "d"
IF RND < .7 THEN choice$ = "d" ELSE choice$ = "c"
IF mymon < otmon THEN choice$ = "d"

CASE 7
name$(7) = "Gina"
descr$(7) = "Looser"
IF otlast$ = "c" THEN choice$ = "c"
IF nom = 10 THEN choice$ = "c"

CASE 8
name$(8) = "Holly"
descr$(8) = "Nice start"
IF otfirst$ = "c" THEN choice$ = "c"
IF RND > .2 THEN choice$ = "c"

CASE 9
name$(9) = "Tim"
descr$(9) = "Normal Strategy"
IF INSTR(otrecord$, "dd") THEN choice$ = "d"
IF INSTR(otrecord$, "dcd") THEN choice$ = "d"
IF INSTR(otrecord$, "cc") THEN choice$ = "c"
IF INSTR(otrecord$, "cdc") THEN choice$ = "c"

CASE 10
name$(10) = "Agent Michi"
descr$(10) = "Big Agent"
IF INSTR(otrecord$, "dd") THEN choice$ = "d"
IF INSTR(otrecord$, "dcd") THEN choice$ = "d"

CASE 11
name$(11) = "King"
descr$(11) = "Cheater"
REM choice$ = "d"
IF otlast$ = "c" THEN choice$ = "d"

CASE 12
name$(12) = "Juliane"
descr$(12) = "uncooperative strategy"
choice$ = "d"

CASE 13
name$(13) = "Mary"
descr$(13) = "clever strategy"
IF INSTR(otrecord$, "dcd") THEN choice$ = "d"
IF INSTR(otrecords$, "ddc") THEN choice$ = "d"

CASE 14
name$(14) = "NO Return"
descr$(14) = "cheaty"
choice$ = "d"
IF RND > .2 THEN choice$ = "d" ELSE choice$ = "c"

CASE 15
name$(15) = "Mother Theresa"
descr$(15) = "Killswitch 2"
choice$ = "d"
IF INSTR(otrecord$, "dd") THEN choice$ = "d"
IF INSTR(otrecord$, "dcd") THEN choice$ = "d"
IF otlast$ = "d" OR otfirst$ = "d" THEN choice$ = "d"

CASE 16
name$(16) = "Niko Robin"
descr$(16) = "Nemesis"
IF INSTR(otrecord$, "d") THEN choice$ = "c" ELSE choice$ = "d"
IF mylast$ = "c" THEN choice$ = "c"

CASE 17
name$(17) = "Katharina"
descr$(17) = "Tricky strategy"
IF mymon < otmon THEN choice$ = "d"
IF otfirst$ = "d" THEN choice$ = "d"

CASE 18
name$(18) = "Nurcan"
descr$(18) = "uncooperativ strategy 2"
choice$ = "d"
IF mylast$ = "c" THEN choice$ = "d"

CASE 19
name$(19) = "Campino"
descr$(19) = "till the bitter ending"
IF INSTR(otrecord$, "dd") THEN choice$ = "d"
IF INSTR(otrecord$, "dcd") THEN choice$ = "d"
IF nom = 10 THEN choice$ = "d"

CASE 20
name$(20) = "T's Timmy"
descr$(20) = "defect till they coop"
choice$ = "d"
IF otlast$ = "c" THEN choice$ = "c"

CASE 21
name$(21) = "T's Uriel"
descr$(21) = "d t t c  but no double cheats"
choice$ = "d"
IF otfirst$ = "c" THEN choice$ = "c"
IF INSTR(otrecord$, "dd") THEN choice$ = "d"

CASE 22
name$(22) = "T's Vernon"
descr$(22) = "defect till double coop"
choice$ = "d"
IF INSTR(otrecord$, "cc") THEN choice$ = "c"
IF mymonfrom > otmonfrom THEN choice$ = "c"

CASE 23
name$(23) = "T's Walter"
descr$(23) = "less money"
IF mymonfrom < otmonfrom THEN choice$ = "d"

CASE 24
name$(24) = "T's Xaver"
descr$(24) = "50 50 plus start finish"
IF RND < .5 THEN choice$ = "d"
IF otfirst$ = "c" AND otlast$ = "c" THEN choice$ = "c"

CASE 25
name$(25) = "T's Yps"
descr$(25) = "80 p c defection"
IF RND < .8 THEN choice$ = "d"

CASE 26
name$(26) = "T's Zelda"
descr$(26) = "unfriendly start then always nice"
IF nom = 1 THEN choice$ = "d" ELSE choice$ = "c"

END SELECT

IF choice$ = "c" OR choice$ = "d" THEN zzz = zzz ELSE GOTO again

REM ...................................................................

IF side$ = "l" THEN lchoice$ = choice$
IF side$ = "r" THEN rchoice$ = choice$
IF side$ = "l" THEN side$ = "r": GOTO changeside
result$ = lchoice$ + rchoice$

PRINT
PRINT CHR$(lepl + 96); " chooses "; lchoice$
PRINT CHR$(ripl + 96); " chooses "; rchoice$

SELECT CASE result$

CASE "cc"
PRINT CHR$(lepl + 96); " gets 3"
PRINT CHR$(ripl + 96); " gets 3"
money(lepl) = money(lepl) + 3: money(ripl) = money(ripl) + 3
moneyfrom(lepl, ripl) = moneyfrom(lepl, ripl) + 3: moneyfrom(ripl, lepl) = moneyfrom(ripl, lepl) + 3
record$(lepl, ripl) = record$(lepl, ripl) + "c": record$(ripl, lepl) = record$(ripl, lepl) + "c"

CASE "cd"
PRINT CHR$(lepl + 96); " gets 0"
PRINT CHR$(ripl + 96); " gets 5"
money(lepl) = money(lepl) + 0: money(ripl) = money(ripl) + 5
moneyfrom(lepl, ripl) = moneyfrom(lepl, ripl) + 0: moneyfrom(ripl, lepl) = moneyfrom(ripl, lepl) + 5
record$(lepl, ripl) = record$(lepl, ripl) + "c": record$(ripl, lepl) = record$(ripl, lepl) + "d"

CASE "dc"
PRINT CHR$(lepl + 96); " gets 5"
PRINT CHR$(ripl + 96); " gets 0"
money(lepl) = money(lepl) + 5: money(ripl) = money(ripl) + 0
moneyfrom(lepl, ripl) = moneyfrom(lepl, ripl) + 5: moneyfrom(ripl, lepl) = moneyfrom(ripl, lepl) + 0
record$(lepl, ripl) = record$(lepl, ripl) + "d": record$(ripl, lepl) = record$(ripl, lepl) + "c"

CASE "dd"
PRINT CHR$(lepl + 96); " gets 1"
PRINT CHR$(ripl + 96); " gets 1"
money(lepl) = money(lepl) + 1: money(ripl) = money(ripl) + 1
moneyfrom(lepl, ripl) = moneyfrom(lepl, ripl) + 1: moneyfrom(ripl, lepl) = moneyfrom(ripl, lepl) + 1
record$(lepl, ripl) = record$(lepl, ripl) + "d": record$(ripl, lepl) = record$(ripl, lepl) + "d"

END SELECT

tor(lepl) = tor(lepl) + 1: tor(ripl) = tor(ripl) + 1

b$ = INKEY$: IF b$ = "q" THEN STOP
IF lepl = moni AND nom = moves THEN SLEEP waiting
newdice:
NEXT ripl
NEXT lepl
NEXT nom

SCREEN 0: WIDTH 80, 43

FOR n = 1 TO 26
PRINT letter$(n); n, money(n), letter$(n); " "; name$(n);
LOCATE n, 46: PRINT descr$(n)
NEXT n

REM ..................... matrix of gold gained .......................

PRINT
PRINT "Press key to see matrix of all gold gained from meeting other ships"
waitforkeyagain:
b$ = INKEY$: IF b$ = "" THEN GOTO waitforkeyagain

CLS
ende = 26
FOR n = 1 TO ende
FOR k = 1 TO 26
LOCATE n, -2 + k * 3: PRINT moneyfrom(n, k);
NEXT k
LOCATE n, 80: PRINT letter$(n);
NEXT n

PRINT
PRINT "Press key to see rankings"
waitforkey:
b$ = INKEY$: IF b$ = "" THEN GOTO waitforkey

FOR a = 1 TO 50
FOR n = 1 TO 25
IF money(n) > money(n + 1) THEN GOTO letitbe
b$ = letter$(n): letter$(n) = letter$(n + 1): letter$(n + 1) = b$
b = money(n): money(n) = money(n + 1): money(n + 1) = b
b$ = name$(n): name$(n) = name$(n + 1): name$(n + 1) = b$
b$ = descr$(n): descr$(n) = descr$(n + 1): descr$(n + 1) = b$
letitbe:
NEXT n
NEXT a

REM ............. show ranking ..................

CLS
FOR n = 1 TO 26
PRINT n
LOCATE n, 5: PRINT money(n)
LOCATE n, 13: PRINT letter$(n); "  "; (ASC(letter$(n)) - 96),
PRINT name$(n);
LOCATE n, 46: PRINT descr$(n)
NEXT n


Back to ToR Home