-
Notifications
You must be signed in to change notification settings - Fork 0
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
code has been improvised to generate fast response #15
base: main
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function name makes it difficult to understand what is being done from the outside.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay I will change the function name.
pkg/controllers/gacha-controller.go
Outdated
i++ | ||
} | ||
// Batch insert user characters into the database | ||
if err := models.CreateUserCharacterBatch(userCharacters); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
@@ -141,59 +143,46 @@ func HandleGachaDraw(w http.ResponseWriter, r *http.Request) { | |||
http.Error(w, "Internal Server Error", http.StatusInternalServerError) | |||
return | |||
} | |||
characterPool := generateCharacterPool(characters) | |||
characterPool := GenerateCharacterPool(characters) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the reason for capitalization?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no reason, I just liked it that way 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@iamananya
In Golang, case has meaning.
You need to look up the Golang specs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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:
GenerateCharacterPool
function 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.FindCharacterByID
function 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.DrawCharacter
function