GithubHelp home page GithubHelp logo

Comments (6)

senzi avatar senzi commented on June 30, 2024

AI不需要随机性

仅仅从游戏性来说,AI是不太需要这种随机性的东西。禁用Math.random之后胜负就能确定。(输的心服口服)
在有高级一点算法的辅助下是可以不需要这个函数的

去掉也挺纠结

这是因为不是每个人都能考虑每种情况去执行命令。在前期需要Math.random让代码能跑起来。
而且完全脱离Math.random可能需要自己写比较高级的函数辅助。

可以先不禁止Math.random,但是给大家说明一下
(有可能的话,在编辑器中出现Math.random就提醒)
可以给一周的延缓期,并且声明一周后使用Math.random会造成代码出错

from codegame.

SakuraSa avatar SakuraSa commented on June 30, 2024

如果是为了包整结果的为一性,我觉得可以将Math.random的随机数种子设值为和账号相关的值(例如用户明,用户id)
这样的话,每个人就都会用有一个独特而又固定的随机序列
这样大家既可以用Math.random,又可以让对站结果固定

from codegame.

chairuosen avatar chairuosen commented on June 30, 2024

有些地方确实要random。比如没有星星,没有敌方,前方有石头,这时候往左拐还是右呢?

from codegame.

liutianyu avatar liutianyu commented on June 30, 2024

实例文档给的就是用的random,http://codegame.org/doc/api 。所以用的人多。

from codegame.

luin avatar luin commented on June 30, 2024

把方案调整为 @SakuraSa 说的那样,以代码的 md5 为随机种子如何。这样对同一份代码来说 Math.random 返回的值依然是完全随机的,不过重复运行代码时生成的随机数是相同的。

from codegame.

senzi avatar senzi commented on June 30, 2024

@luin 同意!就这么改吧,只要Math.random的结果是固定的就挺好的。

from codegame.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.