コード例 #1
0
from pyludo import LudoGame
from pyludo.StandardLudoPlayers import LudoPlayerRandom, LudoPlayerFast, LudoPlayerAggressive, LudoPlayerDefensive
import random
import time

import sys
sys.path.append('pyludo/')
from Qludo import Qludo
myplayer = Qludo()

players = [
    myplayer,
    LudoPlayerRandom(),
    LudoPlayerRandom(),
    LudoPlayerRandom()
    #LudoPlayerFast(),
    #LudoPlayerAggressive(),
    #LudoPlayerDefensive(),
]

myplayer.learning_rate = 0.02
myplayer.discount_rate = 0.01

scores = {}
for player in players:
    scores[player.name] = 0

n = 200
m = 1000

for j in range(m):
コード例 #2
0
from pyludo import LudoGame, LudoPlayerRandom
import random
import time

import sys
sys.path.append('pyludo/')
from Qludo import Qludo

players = [LudoPlayerRandom() for _ in range(3)]
players.append(Qludo())
for i, player in enumerate(players):
    player.id = i

score = [0, 0, 0, 0]

n = 1000

start_time = time.time()
for i in range(n):
    random.shuffle(players)
    ludoGame = LudoGame(players)
    winner = ludoGame.play_full_game()
    score[players[winner].id] += 1
    print('Game ', i, ' done')
duration = time.time() - start_time

print('win distribution:', score)
print('games per second:', n / duration)
コード例 #3
0
from pyludo import LudoGame
from pyludo.StandardLudoPlayers import LudoPlayerRandom, LudoPlayerFast, LudoPlayerAggressive, LudoPlayerDefensive
import random
import time

import sys

sys.path.append('pyludo/')
from Qludo import Qludo

myplayer = Qludo()

players = [
    myplayer,
    LudoPlayerRandom(),
    LudoPlayerRandom(),
    LudoPlayerRandom()
    #LudoPlayerFast(),
    #LudoPlayerAggressive(),
    #LudoPlayerDefensive(),
]

myplayer.learning_rate = 0.05
myplayer.discount_rate = 0.005

scores = {}
for player in players:
    scores[player.name] = 0

n = 200
m = 1000
コード例 #4
0
from pyludo import LudoGame
from pyludo.StandardLudoPlayers import LudoPlayerRandom, LudoPlayerFast, LudoPlayerAggressive, LudoPlayerDefensive
import random
import time
import math

import sys
sys.path.append('pyludo/')
from Qludo import Qludo
myplayer = Qludo()

players = [
    myplayer,
    LudoPlayerRandom(),
    LudoPlayerRandom(),
    LudoPlayerRandom()
    #LudoPlayerFast(),
    #LudoPlayerAggressive(),
    #LudoPlayerDefensive(),
]

training_scores = {}
q_scores = {}
for player in players:
    q_scores[player.name] = 0
for player in players:
    training_scores[player.name] = 0

m = 200
n = 100
t = 5