Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【LocalNouns】都道府県ランダムミント時の割合設定 #158

Merged
merged 11 commits into from
Nov 1, 2023

Conversation

EibaKatsu
Copy link
Collaborator

人口比率に応じて、都道府県を5段階(A~E)にランク分けし、その割合に応じて都道府県を決定する
image

最初にランダム値でA~Eのどのランクの都道府県にするか決定(表中の割当数で重み付け)
uint256[5] ratioRank = [5, 4, 3, 3, 2];

ランク決定後、そのランク内の都道府県のどれにするか、ランダム値で決定

   prefectureRatio[0] = [13, 14, 27, 23, 11, 12, 28, 1, 40];
    prefectureRatio[1] = [22, 8, 34, 26, 4, 15, 20, 21, 10];
    prefectureRatio[2] = [9, 33, 7, 24, 43, 46, 47, 25, 35];
    prefectureRatio[3] = [29, 38, 42, 2, 3, 17, 44, 45, 6, 16];
    prefectureRatio[4] = [37, 5, 30, 19, 41, 18, 36, 39, 32, 31];

EibaKatsu and others added 5 commits June 17, 2023 10:55
* duplicate from sushi-Nouns

* correct Contract name

* correct Contrant name

* deploy NotoSans font

* add font view

* add font components

* fix type and required

* update font address

* format

* update @openzeppelin/contracts

* update package

* update package

* update packages

* LocalNouns initial working version

---------

Co-authored-by: isamu arimoto <[email protected]>
Co-authored-by: Takuya Mizutani <[email protected]>
Co-authored-by: Satoshi Nakajima <[email protected]>
uint256 totalPrefectureRatio;

uint256[5] ratioRank = [5, 4, 3, 3, 2];
uint256[5] acumurationRatioRank;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

acumuration -> accumulation

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

修正しました
4b6a322

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cも2つ必要です。

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

accumulation
です。

prefectureRatio[3] = [29, 38, 42, 2, 3, 17, 44, 45, 6, 16];
prefectureRatio[4] = [37, 5, 30, 19, 41, 18, 36, 39, 32, 31];

for (uint256 i = 0; i < ratioRank.length; i++) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

コストラクタで計算するより値を与えておいたほうが良い気がしますが、こっちのほうがガス代が安い?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ご指摘通りです、、、
25178fd

@@ -184,4 +232,41 @@ contract LocalNounsProvider is IAssetProviderExMint, IERC165, Ownable {
function getPrefectureId(uint256 _tokenId) external override returns (uint256) {
return tokenIdToPrefectureId[_tokenId];
}
=======
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ここはコンフリクトの残り?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

コンフリクトのマージ失敗していたので全て修正しました。
3ccd9a1

function mint(uint256 prefectureId, uint256 _assetId) external returns (uint256) {
bool randomValueForTest = false;

function setRandomValueForTest(bool _test) public onlyOwner {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ここの変更はオーナーしかできないですが、オーナーが変更してtrueのときには、誰でもdeterminePrefectureIdでassetIdを指定できます。
デプロイ後はtrueにしないほうがよいですね。

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hardhatテストでだけ使用するようにします

prefectureRatio[4] = [37, 5, 30, 19, 41, 18, 36, 39, 32, 31];

for (uint256 i = 0; i < ratioRank.length; i++) {
acumurationRatioRankTotal += ratioRank[i];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

memo
acumurationRatioRankTotal = sum ([5, 4, 3, 3, 2])
acumurationRatioRank = [5, 9, 12, 15, 17]

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

コードで定義するようにしました。
sumが使えるのですね。覚えておきます。

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uint256[5] acumulationRatioRank = [5, 9, 12, 15, 17];
uint256 acumulationRatioRankTotal = 17;
ですね(追加されたコードから)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sumは使えません。擬似コードです(メモ用)

@EibaKatsu EibaKatsu merged commit b5233b5 into Cryptocoders-wtf:main Nov 1, 2023
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants