update
This commit is contained in:
@@ -8,31 +8,26 @@ func _initialize() -> void:
|
||||
var games := 100
|
||||
var r := RandomNumberGenerator.new()
|
||||
r.seed = 0
|
||||
var starter := Profile.starter().deck_cards()
|
||||
var random_deck := func(rr: RandomNumberGenerator) -> Array:
|
||||
var pool: Array = Cards.ELEMENTS.duplicate()
|
||||
Game.shuffle(pool, rr)
|
||||
return Game.build_opponent_deck(rr, [pool[0], pool[1]])
|
||||
var t0 := Time.get_ticks_msec()
|
||||
print("Alle gierig (Erwartung etwa 1/(Gegner+1)):")
|
||||
for n in range(1, Game.MAX_OPPONENTS + 1):
|
||||
_run("Zufallsdeck", random_deck, n, games, r, true, true)
|
||||
_run(n, games, r, true, true)
|
||||
print("Du mit Vorausschau, Gegner gierig:")
|
||||
for n in [1, 2, 3]:
|
||||
_run("Zufallsdeck", random_deck, n, games / 2, r, false, true)
|
||||
_run(n, games / 2, r, false, true)
|
||||
print("Alle mit Vorausschau:")
|
||||
_run("Starterdeck", func(_rr): return starter, 1, games / 2, r, false, false)
|
||||
_run("Zufallsdeck", random_deck, 2, games / 4, r, false, false)
|
||||
_run(1, games / 2, r, false, false)
|
||||
_run(2, games / 4, r, false, false)
|
||||
print("Dauer %.1f s" % ((Time.get_ticks_msec() - t0) / 1000.0))
|
||||
quit()
|
||||
|
||||
|
||||
func _run(label: String, deck_fn: Callable, n_opp: int, games: int, r: RandomNumberGenerator,
|
||||
func _run(n_opp: int, games: int, r: RandomNumberGenerator,
|
||||
human_greedy: bool, opp_greedy: bool) -> void:
|
||||
var wins := 0
|
||||
var turns := 0
|
||||
for i in games:
|
||||
var g := Game.new_battle(deck_fn.call(r), n_opp, r)
|
||||
var g := Game.new_battle(n_opp, r)
|
||||
while g.winner == "":
|
||||
var p := g.current()
|
||||
AI.take_turn(g, p, human_greedy if p.is_human else opp_greedy)
|
||||
@@ -40,4 +35,4 @@ func _run(label: String, deck_fn: Callable, n_opp: int, games: int, r: RandomNum
|
||||
if g.winner == "human":
|
||||
wins += 1
|
||||
turns += g.turn
|
||||
print("%-26s vs %d: Siege %3d%% Ø Züge %.1f" % [label, n_opp, wins * 100 / games, float(turns) / games])
|
||||
print("gegen %d: Siege %3d%% Ø Züge %.1f" % [n_opp, wins * 100 / games, float(turns) / games])
|
||||
|
||||
Reference in New Issue
Block a user