Browse Source

power phrases tester

vm
kaos 9 years ago
parent
commit
c5d95da7c5
3 changed files with 262 additions and 4 deletions
  1. +153
    -0
      Phrases of power
  2. +13
    -4
      filterResults.py
  3. +96
    -0
      testPhrases.py

+ 153
- 0
Phrases of power View File

@ -0,0 +1,153 @@
ph'nglui mglw'nafh cthulhu r'lyeh wgah'nagl fhtagn.
#ph'nglui mglw'nafh cthulhu r'lyeh wgah'nagl fhtagn
#ph'nglui mglw'nafh cthulhu r'lyeh wgah'nagl fhtagn!
mglw'nafh fhthagnngah cf'ayak 'vulgtmm vugtlag'n.
ph'nglui
mglw'nafh
#cthulhu r'lyeh
wgah'nagl
fhtagn
helsinki
ia! ia!
ia!
ei!
conway
cocke
hopcroft
backus
conway.
cocke.
hopcroft.
backus.
conway. cocke. hopcroft. backus.
pentacol
elder sign
providence
bigboote
john bigboote
bigbooty
bigbootay
the shadow over innsmouth
y'ha nthlei
y'hanthlei
yoharneth lahai
yoharnethlahai
Devil's Reef
pluto
deep ones
davar
shoggoth
both species have the right to exist on earth.
old ones
in his house at r'lyeh dead cthulhu waits dreaming.
charybdis
scylla
buckaroo banzai
buckaroo
banzai
#books
the whisperer in darkness
#gods, great old olds, and other eldritch beings
azathoth
cthulhu
dagon
nodens
nyarlathotep
#with -
shubniggurath
shub niggurath
yog sothoth
yogsothoth
#tomes
necronomicon
pnakotic manuscripts
de vermis mysteriis
book of eibon
eltdown shards
nameless cults
unaussprechlichen kulten
#things
elder sign
locations
arkham
dunwich
innsmouth
kadath
kingsport
leng
miskatonic
r'lyeh
r'lyeh
yuggoth
irem
#word
hideous
squamous
bas relief
gregarious
shantaks
#wikipedia
pascoag
chepachet
binger
copp's hill
red line
pawtuxet
newburyport
ipswich
dunedin
ayer
bolton
salem
brattleboro
albany
danvers state hospital
catskill mountains
new york city
mainalo mountain
tegea
kilderry
nome
noatak
fort morton
new orleans
newport
paterson
mammoth cave
oslo
hex
#characters
Wilbur Whateley
Professor Henry Armitage
Henry Akeley
Charles Dexter Ward
Nyarlathotep
Azathoth
Kadath
chthonian
ShubNiggurath
Tsathoggua
Byakhee
Ghoul
Ghast
Gug
Yith
Migo
Shantaks
Shantaks'

+ 13
- 4
filterResults.py View File

@ -77,13 +77,23 @@ else:
serverResults[key] = result
if not key in serverScores or serverScores[key] < result['score']:
serverScores[key] = result
serverBestResults = {}
for result in results:
key = str(result['problemId'])+"."+str(result['seed'])
if serverScores[key]['score'] != None and result['score'] > serverScores[key]['score']:
if not key in serverBestResults or serverBestResults[key] < result['score']:
serverBestResults[key] = result
print "Submitted solution: %d"%len(serverResults)
for serverBestResultKey in serverBestResults:
if serverBestResultKey in serverBestResults and serverBestResultKey in serverScores:
if serverBestResults[serverBestResultKey]['score'] > serverScores[serverBestResultKey]['score']:
print bcolors.WARNING + "a older solution with better score exists on server: %d %d %s"%(result['problemId'],result['seed'],result['solution']) + bcolors.ENDC
tags = {}
for serverResult in serverResults:
if not serverResults[serverResult]['tag'] in tags:
tags[serverResults[serverResult]['tag']] = 1
else:
tags[serverResults[serverResult]['tag']] += 1
print "Submitted solution: %d"%len(serverResults)
for solutionToSend in solutionsToSend:
key = str(solutionToSend['problemId'])+"."+str(solutionToSend['seed'])
if not key in serverResults:
@ -103,9 +113,8 @@ else:
print bcolors.WARNING + str(solutionToSend['problemId'])+" "+str(solutionToSend['seed']) + " solution evaluation pending" + bcolors.ENDC
elif scores[key] != serverResults[key]['score']:
print bcolors.FAIL + str(solutionToSend['problemId'])+" "+str(solutionToSend['seed']) + " score differ: " + str(scores[key]) + " != " + str(serverResults[key]['score']) + " (server)" + bcolors.ENDC
elif serverScores[key]['score'] > scores[key]:
print bcolors.FAIL + str(solutionToSend['problemId'])+" "+str(solutionToSend['seed']) + " better solution alredy exists on the server: " + serverScores[key]['solutions'] + bcolors.ENDC
print 32432432
elif key in scores and serverScores[key]['score'] > scores[key]:
print bcolors.FAIL + str(solutionToSend['problemId'])+" "+str(solutionToSend['seed']) + " better solution alredy exists on the server: " + serverScores[key]['solution'] + bcolors.ENDC
elif not key in serverScores:
print "cazziammolla"
print "Tags statistics:"


+ 96
- 0
testPhrases.py View File

@ -0,0 +1,96 @@
#!/usr/bin/env python
import subprocess
import sys
import json
def stringToCommandSequence(string):
commandsSequence = ""
phrase = ""
string = string.lower()
for char in string:
found = False
for i in range(0, len(characters)):
if char in characters[i]:
phrase += characters[i][0]
commandsSequence += commands[i]
found = True
continue
if found == False:
print "error in conversion: %s, %s"%(string, char)
sys.exit(1)
return phrase
commands = ['MoveW',
'MoveE',
'MoveSW',
'MoveSE',
'RotateClockwise',
'RotateCounterclockwise']
characters = [['p', "'", '!', '.', '0', '3'],
['b', 'c', 'e', 'f', 'y', '2'],
['a', 'g', 'h', 'i', 'j', '4'],
['l', 'm', 'n', 'o', ' ', '5'],
['d', 'q', 'r', 'v', 'z', '1'],
['k', 's', 't', 'u', 'w', 'x']]
with open('Phrases of power') as f:
phrases = f.readlines()
f.close()
process = subprocess.Popen(['curl --user :2aaFCkjNIDHAsAIh9iQHc+Y+FGhkM5Z0RQgpO6TL6EA= -X GET https://davar.icfpcontest.org/teams/235/solutions'], shell = True, stdout=subprocess.PIPE)
out, err = process.communicate()
if err == None:
serverResults = json.loads(out)
else:
print "unable to fetch server"
sys.exit(1)
powerPhrases = []
for phrase in phrases:
phrase = phrase.lower()
if phrase != "\n" and phrase[0] != '#':
found = False
for serverResult in serverResults:
if serverResult['solution'].encode('ascii','replace') == phrase[:-1]:
found = True
if serverResult['powerScore'] > 0:
print "Eureka! %s powerScore: %s score: %s"%(phrase[:-1], serverResult['powerScore'], serverResult['score'])
powerPhrases.append(phrase[:-1])
break
elif serverResult['powerScore'] is None:
print " Evaluation pending on %s"%phrase[:-1]
break
else:
#print "No powerScore on %s"%phrase[:-1]
break
if found:
continue
for i in range (0, 25):
process = subprocess.Popen(['src/TestSolution -f sample_problems/problem_'+str(i)+'.json -n 0 -p ' + stringToCommandSequence(phrase[:-1])], shell = True, stdout=subprocess.PIPE)
out, err = process.communicate()
if err == None and out.find("Error") == -1 and out.find("Irrefutable") == -1:
break
if err == None and out.find("Error") == -1 and out.find("Irrefutable") == -1:
OUTPUT=('[{"seed":0,"tag":"shapeShifter","solution":"%s","problemId":12}]'%phrase[:-1]).replace('"', "\\\"")
process = subprocess.Popen(['curl --user :2aaFCkjNIDHAsAIh9iQHc+Y+FGhkM5Z0RQgpO6TL6EA= -X POST -H "Content-Type: application/json" -d "' + OUTPUT + '" https://davar.icfpcontest.org/teams/235/solutions'], shell = True, stdout=subprocess.PIPE)
out, err = process.communicate()
if err == None and out == "created":
print "%s sended"%phrase[:-1]
else:
print out
print " %s unable to comunicate with server"%phrase[:-1]
else:
print " %s return error"%phrase[:-1]
print "\n%d power phrases found:"%len(powerPhrases)
for powerPhrase in powerPhrases:
print powerPhrase
#print "\n%d power phrases found only on server:"%len(powerPhrases)
#for serverResult in serverResults:
# if serverResult['powerScore'] > 0:
# if serverResult['solution'].replace('\n', '') not in powerPhrases:
# print serverResult['solution'], serverResult['powerScore']

Loading…
Cancel
Save