Peter's BlogPeter's Blog

关于攻击距离判定的思路

在解包数据的unit_data.sql中,有一个字段叫search_area_width,之前一直以为等同于攻击距离,但是直接用这个判定之后发现结果有一定的误差。后来在这个帖子中找到了一个靠谱的解答,就向这个答案的回答者無の盡请教了一下,并把他的TypeScript版本计算代码改写成了Golang版本,顺便精简了一下并优化了性能。

Read more...

The performance optimization of the $nin operator in MongoDB

According to the MongoDB official document:

The inequality operator $nin is not very selective since it often 
matches a large portion of the index. As a result, in many cases, 
a $nin query with an index may perform no better than a $nin query 
that must scan all documents in a collection. 

It is not recommended to use $nin operator in a production server because it will often do a full collection scan. But in my project, I have to query some results which does not contain some elements. So I started to optimize the performance.

Read more...

TypeScript with Redux store in a child component

When I was designing some general components in my website, there are some data to be read in redux store. With TypeScript, we can simply use connect and mapStateToProps like this:

Read more...

A Go imlementation of Discrete Probability Distribution

In the mobile game Princess Connect Re:Dive, you can battle with other players in a 5v5 arena. In this arena, you only need to select your team with 5 units and the battle progress is fully automatic. So building a strong team is really important.

I'm building a function to generate a random team which based on the unit strength. Unit strength is easy to get because I have a database which record each match, and the unit strength should be the occurrence of one unit in all matches divided by the occurrence of all units. So the final question is, how can I choose a unit randomly by the unit strength?

Read more...

自动配队的实现思路

事情起源于和森佬折腾小仓唯机器人的娱乐功能。

因为机器人的抽卡已经做的比较完善了,每个人都有了自己的box信息,而这些信息目前来说除了晒欧/非之外并没有任何用处。所以就想着搞一个根据自己的box来群内pvp(咕咕咕)

假设群内对战双方为A和B,完成这个需求需要以下几个步骤:

Read more...

Latest Updates

关于攻击距离判定的思路
The performance optimization of the $nin operator in MongoDB
TypeScript with Redux store in a child component
A Go imlementation of Discrete Probability Distribution
自动配队的实现思路

Tags

AlgorithmGame DataGolangMongoDBNode.JSPerformance optimizationPrincess ConnectReact.JSTypeScript