Conversation
|
Also the results for R=16/20 which is 80% probability SR=3/20 which is 15% probability SSR=1/20 which is 5% probability { |
|
I confirm that it has been more efficient. |
|
@iamananya The proof is not enough. |
Yes I only checked the rarity. I will show you the proof of 10000 times data as well. |
Yes they are not stored 🥲. |
I have added in the latest commit @GuiltyMorishita . |
I think it is the following logic.
Therefore, I want you to prove that each character is drawn according to the assumed probability. |
pkg/models/gacha.go
Outdated
| return nil | ||
| } | ||
|
|
||
| func createBatch(tx *gorm.DB, batch []*UserCharacter) error { |
There was a problem hiding this comment.
This function name makes it difficult to understand what is being done from the outside.
There was a problem hiding this comment.
Okay I will change the function name.
| i++ | ||
| } | ||
| // Batch insert user characters into the database | ||
| if err := models.CreateUserCharacterBatch(userCharacters); err != nil { |
There was a problem hiding this comment.
Please name it in a way that makes it clear that you are not creating a batch, but rather creating characters with batch.
There was a problem hiding this comment.
Okay I meant create user's character batch hence I named it that way.However I will change it if it doesn't make understandable.
pkg/controllers/gacha-controller.go
Outdated
| return | ||
| } | ||
| characterPool := generateCharacterPool(characters) | ||
| characterPool := GenerateCharacterPool(characters) |
There was a problem hiding this comment.
What is the reason for capitalization?
There was a problem hiding this comment.
There is no reason, I just liked it that way 😄
There was a problem hiding this comment.
@iamananya
In Golang, case has meaning.
You need to look up the Golang specs.
There was a problem hiding this comment.
@GuiltyMorishita Since this function is not exported, I will make it lowercase.
|
@GuiltyMorishita I have added all the changes suggested by you . Since I needed to prove the correctness. and I was getting some vague results in the previous implementation. Hence I have modified the code as well. |
changes for multiple gacha also added here
|
This PR fixes issue #9 |

@GuiltyMorishita the code have been improved for a fast response using hash tables.

The implementation details are:
GenerateCharacterPoolfunction creates a hash table (probability map) to store the character probabilities. The character ID is used as the key in the hash table, and the probability is the associated value.FindCharacterByIDfunction iterates across the probability map and returns the character for each ID. The function directly retrieves the character using the ID from the hash table rather than scanning through the complete character slice for each character.DrawCharacterfunction