From 75c1e3a9cb882db9937f709f9bf9ac11cfa2258c Mon Sep 17 00:00:00 2001 From: Daniel Axtens Date: Tue, 24 Aug 2010 15:45:54 +0800 Subject: [PATCH] Applied Frenchie's Wash Patch. --- issues.txt | 2 +- src/LICENSE | 19 --- src/SampleAgents.py | 5 +- src/arenas/CSampleAgents.py | 4 +- src/arenas/PythonSampleAgents.py | 4 +- src/link/C/README | 10 +- src/link/C/agents/c_frenchie.c | 160 ------------------ .../C/c-link-lib.xcodeproj/project.pbxproj | 4 +- src/link/C/c_agents.py | 4 +- 9 files changed, 17 insertions(+), 195 deletions(-) delete mode 100644 src/LICENSE delete mode 100644 src/link/C/agents/c_frenchie.c diff --git a/issues.txt b/issues.txt index d6a2c4e..80daf7c 100644 --- a/issues.txt +++ b/issues.txt @@ -1,4 +1,4 @@ - - number of agents can spiral out of control very quickly, e.g. if Frenchie and Angel start duking it out. + - number of agents can spiral out of control very quickly, e.g. if Wash and Angel start duking it out. * Need to make supervisor smart enough to kill montonically increasing sequences. - points table doesn't agree with technicalities doc - agents die after MAX_AGE fights, not MAX_AGE rounds diff --git a/src/LICENSE b/src/LICENSE deleted file mode 100644 index e25c106..0000000 --- a/src/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2008 Luke Williams - -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, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -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/src/SampleAgents.py b/src/SampleAgents.py index 6da30ba..8a3c439 100644 --- a/src/SampleAgents.py +++ b/src/SampleAgents.py @@ -56,8 +56,9 @@ class Streetfighter (BaseAgent): # This is our first bot with any sort of learning capability, based on the LearningAgent base. # Experienced programmers might opt to write their own learning code based on BaseAgent, but it's up to you. -# Frenchie is a simple bot that is by default nice but will permanently turn against any agent that betrays it. -class Frenchie (LearningAgent): +# Wash is a simple bot that is by default nice but will permanently turn against any agent that betrays it. +# "Curse your suddent but inevitable betrayal" - Wash (Firefly) +class Wash (LearningAgent): def Attack (self, foe): attack = RandomAttack () if Loss in LearningAgent.GetWinHistory (self, foe): diff --git a/src/arenas/CSampleAgents.py b/src/arenas/CSampleAgents.py index a49d6df..3ec8edb 100644 --- a/src/arenas/CSampleAgents.py +++ b/src/arenas/CSampleAgents.py @@ -5,7 +5,7 @@ Written by Daniel Axtens for the UCC Programming Competition in Licensed under an MIT-style license: see the LICENSE file for details. ''' -from link.C.c_agents import c_angel, c_lucifer, c_streetfighter, c_frenchie +from link.C.c_agents import c_angel, c_lucifer, c_streetfighter, c_wash class arena: - Agents = [c_angel,c_lucifer,c_streetfighter,c_frenchie] + Agents = [c_angel,c_lucifer,c_streetfighter,c_wash] diff --git a/src/arenas/PythonSampleAgents.py b/src/arenas/PythonSampleAgents.py index 0a710c4..cdaab5f 100755 --- a/src/arenas/PythonSampleAgents.py +++ b/src/arenas/PythonSampleAgents.py @@ -6,9 +6,9 @@ Written by Daniel Axtens for the UCC Programming Competition in Licensed under an MIT-style license: see the LICENSE file for details. ''' -from SampleAgents import Angel, Lucifer, Dummy, Frenchie, Streetfighter +from SampleAgents import Angel, Lucifer, Dummy, Wash, Streetfighter # Import and add your agents here: class arena: - Agents = [Angel,Lucifer,Streetfighter,Frenchie] \ No newline at end of file + Agents = [Angel,Lucifer,Streetfighter,Wash] diff --git a/src/link/C/README b/src/link/C/README index 9afcc16..ad894a7 100644 --- a/src/link/C/README +++ b/src/link/C/README @@ -18,12 +18,12 @@ Your agents live in link.C.c_agents Add them to Agents to get them to do battle. For example, this code imports c_angel, c_lucifer, c_streetfighter and -c_frenchie, as well as the python sample agents, and then battles c_lucifer, -python Frenchie, c_streetfighter and c_angel. It goes at the top of simulate.py. +c_wash, as well as the python sample agents, and then battles c_lucifer, +python Wash, c_streetfighter and c_angel. It goes at the top of simulate.py. # Import and add your agents here: -from link.C.c_agents import c_angel, c_lucifer, c_streetfighter, c_frenchie +from link.C.c_agents import c_angel, c_lucifer, c_streetfighter, c_wash -from SampleAgents import Angel, Lucifer, Dummy, Frenchie, Streetfighter -Agents = [c_lucifer, Frenchie, c_streetfighter, c_angel] +from SampleAgents import Angel, Lucifer, Dummy, Wash, Streetfighter +Agents = [c_lucifer, Wash, c_streetfighter, c_angel] diff --git a/src/link/C/agents/c_frenchie.c b/src/link/C/agents/c_frenchie.c deleted file mode 100644 index c45085e..0000000 --- a/src/link/C/agents/c_frenchie.c +++ /dev/null @@ -1,160 +0,0 @@ -/* - * c_frechie.c - * c-link-lib - * - * Created by Daniel Axtens on 22/04/10. - * Licensed under an MIT-style license: see the LICENSE file for details. - * - */ - -#include -#include -#include - -/* Implement the frenchie bot, that is by default nice but will - permanently turn against any agent that betrays it. - This is trickier in C than in any other language, for a number of reasons: - - there's no classes in C, so we can't just write a generic learning agent - and subclass it. - - your agent has no idea how many agents it's going to battle, or how many - battles it is going to fight, so you've got to do dynamic memory allocation. - (anyone who tries to read the source of the supervisor to find out is liable - to have their program break unexpectedly) - */ - -/* To simplify things, we just look at whether we have lost to a particular agent. - Unlike in the Python version, we don't keep a generic list - This is also done in a inefficient (O(bot-cout)) way. - Implementing a faster version is left as an exercise to the DSA student. */ - -/* Our guess at the number of agents I'm going to fight in my lifetime - (note that this is only a guess, not an upper limit. Do *not* take it as - gospel on the number of agents you're going to see. */ -#define NUMBEROFAGENTSGUESS 100 - -/* The name of the n-th foe who has beaten us */ -char (*defeatingFoes)[MAXFOENAMELEN] = NULL; - -/* The length of the array, and how far we are along it */ -size_t foesLen = 0; -unsigned int foesCount = 0; - -/* an internal function - have I lost to a given foe? */ -int haveLostTo( char * foeName ) { - int foe; - - /* check every foe we know to have defeated us */ - for (foe=0; foe Yes\n", me, foeName ); - return 1; - } - } - - /* this foe not found */ - return 0; -} - - -ATTACKTYPE Attack( char * foeName ) { - ATTACKTYPE attack; - - attack.realAttack = RandomAttack(); - - /* have I lost to this foe? */ - if ( haveLostTo(foeName) ) { - /* Assume they are lying (FIXME: I'm not entirely sure why the python - does what it does: I'm just duplicating.) */ - switch (attack.realAttack) { - case rock: - attack.promisedAttack = scissors; - break; - case paper: - attack.promisedAttack = rock; - break; - default: /* attack = scissors */ - attack.promisedAttack = paper; - break; - } - } else { - /* be nice! */ - attack.promisedAttack = attack.realAttack; - } - - - return attack; -} - - -ITEMTYPE Defend( char * foeName, ITEMTYPE foePromisedAttack ) { - ITEMTYPE defence; - - if (haveLostTo(foeName)) { - /* They've screwed us in the past, assume they're lying and go for the - kill. */ - switch (foePromisedAttack) { - case rock: - defence = scissors; - break; - case paper: - defence = rock; - break; - default: - defence = paper; - break; - } - } else { - /* be nice! */ - defence = foePromisedAttack; - } - - return defence; -} - -/* This is so much less fun in C */ -void Results( char * foeName, int isInstigatedByYou, RESULTTYPE winner, - ITEMTYPE attItem, ITEMTYPE defItem, ITEMTYPE bluffItem, - int pointDelta ) { - - int foe; - - /* check to see if we've initialised our arrays */ - if (defeatingFoes == NULL) { - defeatingFoes = calloc( NUMBEROFAGENTSGUESS, sizeof( MAXFOENAMELEN*sizeof(char) ) ); - foesLen = NUMBEROFAGENTSGUESS; - } - - /* figure out if we lost, which is the only thing we care about - if we didn't, move on. */ - if ((winner == tie) || - (winner==attacker && isInstigatedByYou) || - (winner==defender && !isInstigatedByYou) ) return; - - //fprintf( stderr, "%d\tsaving loss from %s\n", me, foeName ); - - /* if we've already lost the foe, don't store again */ - for (foe=0; foe