Skip to content

Commit

Permalink
Add kai_genes
Browse files Browse the repository at this point in the history
  • Loading branch information
brianmcmichael committed Jan 2, 2019
1 parent a0709e3 commit 0923711
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ Get the .csv (~170mb) and .zip (~70mb) in [Releases](https://github.com/brianmcm
## Output

* Filename: `kittylist.csv`
* CSV Format: `"id", "isGestating", "isReady", "cooldownIndex", "nextActionAt", "siringWithId", "birthTime", "matronId", "sireId", "generation", "genes"`
* CSV Format: `"id", "isGestating", "isReady", "cooldownIndex", "nextActionAt", "siringWithId", "birthTime", "matronId", "sireId", "generation", "genes", "kai_genes"`
17 changes: 14 additions & 3 deletions kittylist.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,17 @@

start_time = time.time()

#print(w3.eth.getBlock('latest'))
# Kai Encoding
ALPHABET = '123456789abcdefghijkmnopqrstuvwx'
BASE = len(ALPHABET)

def kai_encode( num ):
buf = ""
while num >= BASE:
mod = num % BASE
buf = ALPHABET[mod] + buf
num = (num - mod)//BASE
return ALPHABET[num] + buf

CONTRACT_ABI = ""
with open(os.path.join(os.path.dirname(__file__), "cryptokitties.json")) as json_data:
Expand Down Expand Up @@ -59,7 +69,7 @@
with open('kittylist.csv', file_flag) as outcsv:
_headers = [ "id", "isGestating", "isReady", "cooldownIndex", "nextActionAt",
"siringWithId", "birthTime", "matronId", "sireId",
"generation", "genes" ]
"generation", "genes", "kai_genes" ]
writer = csv.DictWriter(outcsv, fieldnames = _headers)
if not read_file:
writer.writeheader()
Expand All @@ -79,7 +89,8 @@
"matronId": _k[6],
"sireId": _k[7],
"generation": _k[8],
"genes": _k[9]
"genes": _k[9],
"kai_genes": kai_encode(_k[9])
})


Expand Down

0 comments on commit 0923711

Please sign in to comment.