

AnkiStrategy
0.01MB. Updated 2013-10-23. Only supports Anki 2.0.
Description
Download
The add-on author has not uploaded a version of this add-on compatible with Anki 2.1. Old add-ons for Anki 2.0 can be downloaded from the archive.Reviews

please update for new version!

I would really like to try this one. By any chance, team can fix this for the newer version?

Great work, I agree that it's definitely the best game add-on.
Any chance it might be updated to work with Anki 2.1? I really miss it!!
Any chance it might be updated to work with Anki 2.1? I really miss it!!

It is the best game add-on, for me at least, but it no longer works with the latest Anki update.

Does not work, blank screen

It isn't working, I was really excited to play the game :(

sadly not working

I imagine an excellent game however with the new update post below, I get this upon opening Anki:
"An error occurred in an add-on.
Please post on the add-on forum:
https://anki.tenderapp.com/discussions/add-ons
Traceback (most recent call last):
File "aqt/addons.pyc", line 41, in loadAddons
File "/Users/seandonaghue/Library/Application Support/Anki2/addons/AnkiStrategy.py", line 8, in <module>
File "/Users/seandonaghue/Library/Application Support/Anki2/addons/ankistrategy/ankistrategymain.py", line 12, in <module>
File "/Users/seandonaghue/Library/Application Support/Anki2/addons/ankistrategy/game.py", line 31
i = int(f)
^
IndentationError: expected an indented block"
"An error occurred in an add-on.
Please post on the add-on forum:
https://anki.tenderapp.com/discussions/add-ons
Traceback (most recent call last):
File "aqt/addons.pyc", line 41, in loadAddons
File "/Users/seandonaghue/Library/Application Support/Anki2/addons/AnkiStrategy.py", line 8, in <module>
File "/Users/seandonaghue/Library/Application Support/Anki2/addons/ankistrategy/ankistrategymain.py", line 12, in <module>
File "/Users/seandonaghue/Library/Application Support/Anki2/addons/ankistrategy/game.py", line 31
i = int(f)
^
IndentationError: expected an indented block"

It's great

We fixed the code for MAC users who want to add city names and AI names. Replace your game.py file with this:
#-*- coding: UTF-8 -*-
#This file is part of AnkiStrategy. Copyright: 2013 <tcp-ip_80@libero.it>
#License: GNU AGPL, version 3 or later.
#This program is intended to be an add-on for Anki 2,
#note that Anki is copyrighted by Damien Elmes, who releases it under the same licence.
#You should have received a copy of the AGPL along with Anki. If not, see http://www.gnu.org/licenses/agpl.html
import random, datetime
#world generation constants
NPLAYERS = 10
NCITIES = 30
BIGGESTCITYSIZE = 3000000
WORLDSIZE = (1000, 600)
#game parameters
PEOPLECHANGINGOPINION = .10
PLAYERCLOUT = 1000
AMBASSADORCLOUT = 500
EXCHANGERATE = 10**-2#2 1 million inhabitants cities 1000Km away exchange 1% of their population
CITYGOVERNMENTPOWER = .02
MAXEXCHANGERATE = .02# A city can't exchange more that this portion of inhabitants per turn
RETURNTONEUTRALRATE = .1
AMBASSADORLIFE = 90#days
#interface
HONORIFICS = ['Peasant', 'Baron', 'Viscount', 'Count', 'Marquis', 'Duke', 'Prince', 'King', 'Emperor']
COLORS = [(255, 255, 255), (0, 0, 0),#[0]=background color and [1]=neutral color
(0, 255, 0), (255, 0, 0), (0, 0, 255), (200, 200, 0), (255,0 ,255), (0, 255, 255),
(127, 255, 0), (255, 127, 0), (0, 127, 255), (200, 200, 127), (255, 127 ,255), (127, 255, 255)]
AINAMES = ['John Howard','George W. Bush','Francisco Pizarro','Mahmud of Ghazni','Napoleon Bonaparte','Adolf Hitler','Attila the Hun','Cyrus The Great','Tamerlane','Alexander The Great','Genghis Khan'];
CITYNAMES = ['Moscow','Berlin','Ankara','Paris','London','Rome','Kiev','Madrid','Warsaw','Bucharest','Amsterdam','Astana','Athens','Brussels','Lisbon','Prague','Budapest','Stockholm','Vienna','Sofia','Copenhagen','Helsinki','Oslo','Dublin','Sarajevo','Luxembourg','Reykjavik','Monaco','San Marino','Vatican City']
def randomRounding(f):
i = int(f)
r = f-i
if random.random()<r:
i += 1
return i
class Player(object):
def evalBestTargetCity(self, world):
'AI evaluation function to find the best target'
strongerEnemy = max([(world.players[x].rank, world.players[x].id) for x in world.players])
values = {}
for i in world.cities:
if self.id in world.cities[i].factions and world.cities[i].factions[self.id]>.5*world.cities[i].size:
value = 0
else:
value = world.cities[i].factions.get(self.id, 0)/float(world.cities[i].size)
if strongerEnemy[1] in world.cities[i].government:
value += strongerEnemy[0]
values[i] = value
bestTargets = [x for x in values if values[x] == max(values.values())]
return random.choice(bestTargets)
def ai(self, world, question):
if question == 'location':
return self.evalBestTargetCity(world)
elif question == 'assignAmbassador':
return self.evalBestTargetCity(world)
else:
raise
def askIntelligence(self, world, question):
assert self.isAI
return self.ai(world, question)
def __init__(self, playerId, name, color):
self.isAI = True
self.id = playerId
self.name = name
self.color = color
self.rank = 0
self.location = None#a city
self.virtues = []#list of virtues in all previous turns
class City(object):
def localFactionChanges(self):
'Exchange of citizens within a city'
#The clout of each player in each city is calculated according to his virtue in this turn and other parameters:
clout = {}
#presence: 1000*virtue if the player is in the city, 500*virtue for each ambassador in the city.
#Some citizens turns back to neutral.
for i in self.playersInCity:
clout[i.id] = clout.get(i.id, 0)+PLAYERCLOUT*i.
#-*- coding: UTF-8 -*-
#This file is part of AnkiStrategy. Copyright: 2013 <tcp-ip_80@libero.it>
#License: GNU AGPL, version 3 or later.
#This program is intended to be an add-on for Anki 2,
#note that Anki is copyrighted by Damien Elmes, who releases it under the same licence.
#You should have received a copy of the AGPL along with Anki. If not, see http://www.gnu.org/licenses/agpl.html
import random, datetime
#world generation constants
NPLAYERS = 10
NCITIES = 30
BIGGESTCITYSIZE = 3000000
WORLDSIZE = (1000, 600)
#game parameters
PEOPLECHANGINGOPINION = .10
PLAYERCLOUT = 1000
AMBASSADORCLOUT = 500
EXCHANGERATE = 10**-2#2 1 million inhabitants cities 1000Km away exchange 1% of their population
CITYGOVERNMENTPOWER = .02
MAXEXCHANGERATE = .02# A city can't exchange more that this portion of inhabitants per turn
RETURNTONEUTRALRATE = .1
AMBASSADORLIFE = 90#days
#interface
HONORIFICS = ['Peasant', 'Baron', 'Viscount', 'Count', 'Marquis', 'Duke', 'Prince', 'King', 'Emperor']
COLORS = [(255, 255, 255), (0, 0, 0),#[0]=background color and [1]=neutral color
(0, 255, 0), (255, 0, 0), (0, 0, 255), (200, 200, 0), (255,0 ,255), (0, 255, 255),
(127, 255, 0), (255, 127, 0), (0, 127, 255), (200, 200, 127), (255, 127 ,255), (127, 255, 255)]
AINAMES = ['John Howard','George W. Bush','Francisco Pizarro','Mahmud of Ghazni','Napoleon Bonaparte','Adolf Hitler','Attila the Hun','Cyrus The Great','Tamerlane','Alexander The Great','Genghis Khan'];
CITYNAMES = ['Moscow','Berlin','Ankara','Paris','London','Rome','Kiev','Madrid','Warsaw','Bucharest','Amsterdam','Astana','Athens','Brussels','Lisbon','Prague','Budapest','Stockholm','Vienna','Sofia','Copenhagen','Helsinki','Oslo','Dublin','Sarajevo','Luxembourg','Reykjavik','Monaco','San Marino','Vatican City']
def randomRounding(f):
i = int(f)
r = f-i
if random.random()<r:
i += 1
return i
class Player(object):
def evalBestTargetCity(self, world):
'AI evaluation function to find the best target'
strongerEnemy = max([(world.players[x].rank, world.players[x].id) for x in world.players])
values = {}
for i in world.cities:
if self.id in world.cities[i].factions and world.cities[i].factions[self.id]>.5*world.cities[i].size:
value = 0
else:
value = world.cities[i].factions.get(self.id, 0)/float(world.cities[i].size)
if strongerEnemy[1] in world.cities[i].government:
value += strongerEnemy[0]
values[i] = value
bestTargets = [x for x in values if values[x] == max(values.values())]
return random.choice(bestTargets)
def ai(self, world, question):
if question == 'location':
return self.evalBestTargetCity(world)
elif question == 'assignAmbassador':
return self.evalBestTargetCity(world)
else:
raise
def askIntelligence(self, world, question):
assert self.isAI
return self.ai(world, question)
def __init__(self, playerId, name, color):
self.isAI = True
self.id = playerId
self.name = name
self.color = color
self.rank = 0
self.location = None#a city
self.virtues = []#list of virtues in all previous turns
class City(object):
def localFactionChanges(self):
'Exchange of citizens within a city'
#The clout of each player in each city is calculated according to his virtue in this turn and other parameters:
clout = {}
#presence: 1000*virtue if the player is in the city, 500*virtue for each ambassador in the city.
#Some citizens turns back to neutral.
for i in self.playersInCity:
clout[i.id] = clout.get(i.id, 0)+PLAYERCLOUT*i.

COOOOL

I'm using Anki 2.0.48 but this addon only give me blank screen...

Great great idea. As some have already said, you should name the cities and players (my opinion? create the names yoursel)
Thanks, buddy, i'll be following this link
Thanks, buddy, i'll be following this link

add flavor: How To
I like the addon, would appreciate to see continued development indeed!
To add to the previous comment, in game.py replace this function to get some nicer city names:
def startGame(self, source):
self.playerNames = ['Human','Franklin D. Roosevelt','Napoleon Bonaparte','Adolf Hitler','Attila the Hun','Alexander The Great','Genghis Khan', 'Winston Churchill', 'Julius Caesar', 'George Washington', 'Abraham Lincoln']
self.cityNames = ["Moscow","London","Berlin","Madrid","Rome","Kiev","Paris","Bucharest","Budapest","Minsk","Warsaw","Vienna","Copenhagen","Prague","Sofia","Belgrade","Podgorica","Riga","Zagreb","Athens","Amsterdam","Stockholm","Chisinau","Lisbon","Vilnius","Dublin","Helsinki","Sarajevo","Oslo","Bratislava","Skopje","Tallinn","Ljubljana","Tirana","Nicosia","Brussels","Bern","Reykjavik","Luxembourg","Monaco","Andorra la Vella","Nuuk","Valletta","Vaduz","San Marino","Vatican City"]
self.turn = 0
self.turnLog = []
#initializing players
self.players[1] = Player(1, 'Human', COLORS[2])
self.players[1].isAI = False
for i in range(2, NPLAYERS+1):
self.players[i] = Player(i, self.playerNames[i], COLORS[i+1])
#initializing world
if type(source) == int:#random cities
r = random.Random()
r.seed(source)
usedCoordinates = set()
for i in range(NCITIES):
coordinates = (r.randint(int(WORLDSIZE[0]*.05), int(WORLDSIZE[0]*.95)), r.randint(int(WORLDSIZE[1]*.05), int(WORLDSIZE[1]*.95)))
while coordinates in usedCoordinates:
coordinates = (r.randint(0, WORLDSIZE[0]-1), r.randint(0, WORLDSIZE[1]-1))
self.cities[self.cityNames[i]] = City(self, coordinates, self.cityNames[i], BIGGESTCITYSIZE/(i+1))
usedCoordinates.add(coordinates)
self.calcCityExchangeRate()
self.WORLDSIZE = WORLDSIZE
else:
raise#TODO (future release) load map from file
#positioning players
for i in self.players:
if not self.players[i].isAI: continue
location = self.players[i].askIntelligence(self, 'location')
self.players[i].location = self.cities[location]
self.cities[location].playersInCity.append(self.players[i])
I like the addon, would appreciate to see continued development indeed!
To add to the previous comment, in game.py replace this function to get some nicer city names:
def startGame(self, source):
self.playerNames = ['Human','Franklin D. Roosevelt','Napoleon Bonaparte','Adolf Hitler','Attila the Hun','Alexander The Great','Genghis Khan', 'Winston Churchill', 'Julius Caesar', 'George Washington', 'Abraham Lincoln']
self.cityNames = ["Moscow","London","Berlin","Madrid","Rome","Kiev","Paris","Bucharest","Budapest","Minsk","Warsaw","Vienna","Copenhagen","Prague","Sofia","Belgrade","Podgorica","Riga","Zagreb","Athens","Amsterdam","Stockholm","Chisinau","Lisbon","Vilnius","Dublin","Helsinki","Sarajevo","Oslo","Bratislava","Skopje","Tallinn","Ljubljana","Tirana","Nicosia","Brussels","Bern","Reykjavik","Luxembourg","Monaco","Andorra la Vella","Nuuk","Valletta","Vaduz","San Marino","Vatican City"]
self.turn = 0
self.turnLog = []
#initializing players
self.players[1] = Player(1, 'Human', COLORS[2])
self.players[1].isAI = False
for i in range(2, NPLAYERS+1):
self.players[i] = Player(i, self.playerNames[i], COLORS[i+1])
#initializing world
if type(source) == int:#random cities
r = random.Random()
r.seed(source)
usedCoordinates = set()
for i in range(NCITIES):
coordinates = (r.randint(int(WORLDSIZE[0]*.05), int(WORLDSIZE[0]*.95)), r.randint(int(WORLDSIZE[1]*.05), int(WORLDSIZE[1]*.95)))
while coordinates in usedCoordinates:
coordinates = (r.randint(0, WORLDSIZE[0]-1), r.randint(0, WORLDSIZE[1]-1))
self.cities[self.cityNames[i]] = City(self, coordinates, self.cityNames[i], BIGGESTCITYSIZE/(i+1))
usedCoordinates.add(coordinates)
self.calcCityExchangeRate()
self.WORLDSIZE = WORLDSIZE
else:
raise#TODO (future release) load map from file
#positioning players
for i in self.players:
if not self.players[i].isAI: continue
location = self.players[i].askIntelligence(self, 'location')
self.players[i].location = self.cities[location]
self.cities[location].playersInCity.append(self.players[i])






Add flavor
To make it a bit less bland, insert lines like these where appropriate in the game.py file:
AIList=['.','George W. Bush','Francisco Pizarro','Mahmud of Ghazni','Napoleon Bonaparte','Adolf Hitler','Attila the Hun','Cyrus The Great','Tamerlane','Alexander The Great','Genghis Khan']
CityList=['Moscow','Berlin','Ankara','Paris','London','Rome','Kiev','Madrid','Warsaw','Bucharest','Amsterdam','Astana','Athens','Brussels','Lisbon','Prague','Budapest','Stockholm','Vienna','Sofia','Copenhagen','Helsinki','Oslo','Dublin','Sarajevo','Luxembourg','Reykjavik','Monaco','San Marino','Vatican City']
To make it a bit less bland, insert lines like these where appropriate in the game.py file:
AIList=['.','George W. Bush','Francisco Pizarro','Mahmud of Ghazni','Napoleon Bonaparte','Adolf Hitler','Attila the Hun','Cyrus The Great','Tamerlane','Alexander The Great','Genghis Khan']
CityList=['Moscow','Berlin','Ankara','Paris','London','Rome','Kiev','Madrid','Warsaw','Bucharest','Amsterdam','Astana','Athens','Brussels','Lisbon','Prague','Budapest','Stockholm','Vienna','Sofia','Copenhagen','Helsinki','Oslo','Dublin','Sarajevo','Luxembourg','Reykjavik','Monaco','San Marino','Vatican City']


Great concept
I think this is a great idea, any progress on getting a mac version to work?
I think this is a great idea, any progress on getting a mac version to work?


Fun side activity while studying
I like this game, even though I am also waiting for some improvements :)
First of all, this only runs on a PC and not a Mac. I hope this will become available some time in the future!
As for the game itself, it would be great if you could add the date for the current turn. I was getting confused on which turn I was ending. Maybe also an overview on how many cards you finished in a certain turn.
Then also I am wondering if there would be a possibility for the game to choose your card goal? I have several decks that I review every day. Sometimes I review less than my goal because there are not enough cards due. On other days, I review more than my goal. Then the game would get too easy, right? Just a few thoughts.
Thanks so much!
I like this game, even though I am also waiting for some improvements :)
First of all, this only runs on a PC and not a Mac. I hope this will become available some time in the future!
As for the game itself, it would be great if you could add the date for the current turn. I was getting confused on which turn I was ending. Maybe also an overview on how many cards you finished in a certain turn.
Then also I am wondering if there would be a possibility for the game to choose your card goal? I have several decks that I review every day. Sometimes I review less than my goal because there are not enough cards due. On other days, I review more than my goal. Then the game would get too easy, right? Just a few thoughts.
Thanks so much!



Awesome! New game option?
Love the concept. It's been awhile since I've played a text-based game, so the UI simplicity is great. Excited to see if there are any future game updates!
One question I have is how to start a new game (perhaps a future update if it's not already integrated into the game?). I added this on awhile ago out of curiosity and then didn't touch Anki for about 2 weeks as I was on break. And now that I'm back at school, it would be great if I was able to start a new game as after 2 weeks of no reviews, I'm put quite behind in the game.
Anyways, thanks again to the developer!
Love the concept. It's been awhile since I've played a text-based game, so the UI simplicity is great. Excited to see if there are any future game updates!
One question I have is how to start a new game (perhaps a future update if it's not already integrated into the game?). I added this on awhile ago out of curiosity and then didn't touch Anki for about 2 weeks as I was on break. And now that I'm back at school, it would be great if I was able to start a new game as after 2 weeks of no reviews, I'm put quite behind in the game.
Anyways, thanks again to the developer!


Waiting for improvements
Thank you for that awesome addon! I'm looking forward to seeing improvements in the future ;-)
Thank you for that awesome addon! I'm looking forward to seeing improvements in the future ;-)

Great idea, keeps me motivated
Honestly more signed on to thank the developer than anything. The game is beyond simple but I think that's appropriate for a game that exists to motivate studying. Often, the desire not to get 0 virtue is the reason I decide not to skip studying. So, thanks developer guy. This is awesome!
Honestly more signed on to thank the developer than anything. The game is beyond simple but I think that's appropriate for a game that exists to motivate studying. Often, the desire not to get 0 virtue is the reason I decide not to skip studying. So, thanks developer guy. This is awesome!


Absolutely fantastic
I freaking love this game - it is literally my biggest incentive to do my anki reps every day. I support this 100% and I would love to see it added on to in whatever way possible. Thank you for taking the time to create this!
I freaking love this game - it is literally my biggest incentive to do my anki reps every day. I support this 100% and I would love to see it added on to in whatever way possible. Thank you for taking the time to create this!

looks promising
I've tried it so far and I like it
I've tried it so far and I like it


Caused Error in Anki, Now I can't load my profile.
I am running Anki an OSX 10.8.5. I have deleted AnkiStrategy and reinstalled Anki and I still can't load my profile.
I am running Anki an OSX 10.8.5. I have deleted AnkiStrategy and reinstalled Anki and I still can't load my profile.


Yes! Really promising!!
Please make an update to develop this. Awesome!! Keeps really motivating.
Please make an update to develop this. Awesome!! Keeps really motivating.

Perfect idea
please improve this add-on
please improve this add-on

So much potential, but currently little better than nothing
To fulfill potential
NAME THE PLAYERS! or at least allow user to do so
NAME THE CITIES! or at least allow user to do so
Place a real world map on the map screen, or facilitate the user to upload a picture and reposition cities
If you were to make this work; you'd be my hero!
To fulfill potential
NAME THE PLAYERS! or at least allow user to do so
NAME THE CITIES! or at least allow user to do so
Place a real world map on the map screen, or facilitate the user to upload a picture and reposition cities
If you were to make this work; you'd be my hero!

Looks promising
Pretty redimentary so far, but still motivates me more than the Anki statistics. Looking forward to future developments!
Pretty redimentary so far, but still motivates me more than the Anki statistics. Looking forward to future developments!
