学习笔记(2):steemmonsters对战模拟器学习

in #spt4 years ago (edited)

https://github.com/Bauloewe/SM_Simulation

@Bauloewe写了一个steemmonsters对战模拟器,虽然里面BUG很多,但是也是非常有参考价值的模拟器。

研究学习一下怎么用模拟器:

#加载库
import time
from api import Api
from Team import Team
from Simulation import SteemMonstersSimulation
import Simulation
import copy

首先加载各种库

#实例化类
api = Api()

#这个是禁止的召唤士
noinactive=""
#这是规则
ai=""
#玩家名字
player="maiyude"
player2="robot"


b1=0
kk=1
zhunque=0

#team1队伍
#怪兽信息都是这个格式{'id': 74, 'level': 2},ID加等级
# 召唤士信息
summoner = {'id': 74, 'level': 2}
monsters = [{'id': 82, 'level': 4},{'id': 48, 'level': 1},{'id': 143, 'level': 1}]



#team2队伍
# 召唤士信息
summoner2 = {'id': 74, 'level': 2}
monsters2 = [{'id': 131, 'level': 3},{'id': 80, 'level': 1},{'id': 214, 'level': 1}]




#加载怪兽信息
sm_dict=simulation.load_SM_dict()

#使用Team.py,加载怪兽的各种信息信息
team1x = Team(summoner, monsters, ai, sm_dict, player)
team2x = Team(summoner2, monsters2, ai, sm_dict, "diren")

#实例化类
battle = SteemMonstersSimulation(team1x, team2x, sm_dict, player)

#获得比赛结果
results = battle.simulate_battle()


#这里我自己做了修改,作者的程序不这样
re=copy.deepcopy(results[0])
re1=copy.deepcopy(results[1])

#比赛结果
if re==1:
    print("team1胜利")
else:
    print("team2胜利")

随便写了一个队伍测试了看看。(信息我稍微汉化了一下)

实际研究发现这个模拟器存在很多BUG。
有大量技能是不生效的,以及新怪物的技能也没有。
有存在怪物死亡一次删除了2只的状态。
需要自己慢慢改。

总体就是好过没有,模拟准确率大概在50-80%左右。

Sort:  

Hi @maiyude!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your UA account score is currently 3.720 which ranks you at #5559 across all Steem accounts.
Your rank has not changed in the last three days.

In our last Algorithmic Curation Round, consisting of 113 contributions, your post is ranked at #56.

Evaluation of your UA score:
  • You're on the right track, try to gather more followers.
  • The readers like your work!
  • Try to work on user engagement: the more people that interact with you via the comments, the higher your UA score!

Feel free to join our @steem-ua Discord server

Hello, I hope English is fine with you. I used Google translator to read your blog post.

Thanks for looking at my simulator :) I'd love to know which bugs you found, so that I can keep improving the simulator.

Regarding the precision of the simulator, I think you can't get better than 70/80% if you don't use the match RNG seed. I haven't added it yet, but might in a future update.

Your work is great, thank you.

I found a few problems:
1.Some skills fail. for example Thorns have failed.
2.miss seem to fail.
3.After the monster dies, it will be deleted repeatedly,The problem is in the following code:

4.No untamed new skills

Thank you :)

  1. I'll look into the skills more thoroughly and clean up my code. Thank you for pointing it out :) There are probably a lot more bugs. I think I need to add more tests to detect those kinds of bugs.

  2. The problem with misses/hits is that they are not deterministic. Whether a monster misses is determined in the match. I'd need to add the seed of a match to my random number generator. And the seed is only known after a match finished. So without the seed, there is some variance there. But I assume that there are some bugs within that part of the code which need fixing :)

  3. That bugs sounds curious. I'll have to take a closer look.

  4. I'm working on the Untamed Skills right now. I've added 70% of them to my local repository. Haven't had time to push it to GitHub. But I'll do that soon.

I hope I'll fix the bugs you've found very soon. Thanks again for taking the time to look at my code :)

I actually came on here to congratulate you @bauloewe on having designed a @splinterlands sim... but I see you're giving that out for free? wow 👏 I guess it's 'simple' but also 'not' ... if you know what I mean. I guess it's depends on the person at the end of the keyboard 😉 As well, I guess impossible to make something '100%' accurate like you say. But still, maybe it's time for me to start learning some python... heh 👍 Right now I am doing a different course but it's been on my mind - certainly would mesh with STEEM well.

Coin Marketplace

STEEM 0.30
TRX 0.12
JST 0.033
BTC 64344.02
ETH 3142.36
USDT 1.00
SBD 4.01