Wait how does seeding work? I never had to do that in python so it is kind of new to me. I tried the love.math.randomseed(os.time()) but it is giving me a nill value error. What else can I seed with?
Thank you friends
"Questions that don't deserve their own thread" thread
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Prole
- Posts: 19
- Joined: Sun Mar 13, 2016 3:23 am
- zorg
- Party member
- Posts: 3465
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: "Questions that don't deserve their own thread" thread
Since most random functions return pseudorandom values, that means that they use some kind of formula internally; the better that formula (meaning more complex, but that's not enough) the better the "randomness" quality of the generator.
A seed is a value that if you give to a pseudo-random generator, and call it n times, with the same seed it will give the same number.
In other words, a pseudo-random sequence is reproducible in this manner, which is a nice thing to have.
Also, you don't need to seed a prng, since in löve (and in python too, i presume, at some point early in the execution, the default prng function's state will be seeded with a number. Whether it's a constant 0 by default, or something random, like os.clock() in lua (that löve uses in it's love.run game loop), it will work and give back values; the same ones always for the former case, and different values for the latter.
Also, i think i kind of answered your question too. (Also, it errors because love.math.randomseed does not exist, that's the name of the lua math function, you want [wiki]love.math.setRandomSeed[/wiki]
A seed is a value that if you give to a pseudo-random generator, and call it n times, with the same seed it will give the same number.
In other words, a pseudo-random sequence is reproducible in this manner, which is a nice thing to have.
Also, you don't need to seed a prng, since in löve (and in python too, i presume, at some point early in the execution, the default prng function's state will be seeded with a number. Whether it's a constant 0 by default, or something random, like os.clock() in lua (that löve uses in it's love.run game loop), it will work and give back values; the same ones always for the former case, and different values for the latter.
Also, i think i kind of answered your question too. (Also, it errors because love.math.randomseed does not exist, that's the name of the lua math function, you want [wiki]love.math.setRandomSeed[/wiki]
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
-
- Prole
- Posts: 19
- Joined: Sun Mar 13, 2016 3:23 am
Re: "Questions that don't deserve their own thread" thread
zorg wrote:Since most random functions return pseudorandom values, that means that they use some kind of formula internally; the better that formula (meaning more complex, but that's not enough) the better the "randomness" quality of the generator.
A seed is a value that if you give to a pseudo-random generator, and call it n times, with the same seed it will give the same number.
In other words, a pseudo-random sequence is reproducible in this manner, which is a nice thing to have.
Awesome thank you friend
I see. I think I have to seed for my case because I'm not using love.runzorg wrote: Also, you don't need to seed a prng, since in löve (and in python too, i presume, at some point early in the execution, the default prng function's state will be seeded with a number. Whether it's a constant 0 by default, or something random, like os.clock() in lua (that löve uses in it's love.run game loop), it will work and give back values; the same ones always for the former case, and different values for the latter.
Oops XD didn't pay attention to that. Thank you friendzorg wrote: Also, i think i kind of answered your question too. (Also, it errors because love.math.randomseed does not exist, that's the name of the lua math function, you want [wiki]love.math.setRandomSeed[/wiki]
Thank you for helping me friends.
Re: "Questions that don't deserve their own thread" thread
You can't be "not using" love.run, it's run by default. It does seed the pRNG, but you have to wait until love.load before using love.math.random if you want it to be automatically seeded.
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
-
- Prole
- Posts: 19
- Joined: Sun Mar 13, 2016 3:23 am
Re: "Questions that don't deserve their own thread" thread
Code: Select all
require'math'
require'os'
WHITE = {255,255,255}
RED = {255,0,0}
YELLOW = {255,255,0}
function love.load()
end
function Block()
local self = {}
self.color = RED
self.x_pos = 20
self.y_pos = 20
function self:drawBlock()
self.image_color = love.graphics.setColor(self.color)
self.image = love.graphics.rectangle('fill', self.x_pos, self.y_pos, 20, 20)
end
return self
end
function MovingBlock()
local self = Block() or {}
local go_right = true
local go_left = false
function self:movement()
if self.x_pos < 0 then
go_right = true
go_left = false
end
if go_right == true then
self.x_pos = self.x_pos + 5
end
if self.x_pos > 500 then
go_left = true
go_right = false
end
if go_left == true then
self.x_pos = self.x_pos - 5
end
end
return self
end
function Player()
local self = Block() or {}
function self:movement()
if love.keyboard.isDown('left') then
self.x_pos = self.x_pos + -5
end
if love.keyboard.isDown('right') then
self.x_pos = self.x_pos + 5
end
if love.keyboard.isDown('up') then
self.y_pos = self.y_pos + -5
end
if love.keyboard.isDown('down') then
self.y_pos = self.y_pos + 5
end
end
return self
end
x = Player()
x.x_pos = love.math.setRandomSeed(os.time()) --WILL NOT WORK WITHOUT THIS CODE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
x.x_pos = love.math.random(0,500)
function love.update(dt)
x.color = x.color == RED and YELLOW or RED
x:movement()
end
function love.draw()
--x.color = YELLOW
x:drawBlock()
end
My ignorance is strongYou can't be "not using" love.run, it's run by default.
Strange I did put love.math.random after love.load() and I still have to set a seed. Sorry for the caps I just put it so that it is easier to see.It does seed the pRNG, but you have to wait until love.load before using love.math.random if you want it to be automatically seeded.
Re: "Questions that don't deserve their own thread" thread
it needs to run after love.run is run, NOT after it is defined. (Actually, seeding happens just before love.run, so what you want to be doing is put the random number inside love.run.)XxHAMADEHxX wrote: Strange I did put love.math.random after love.load() and I still have to set a seed. Sorry for the caps I just put it so that it is easier to see.
Re: "Questions that don't deserve their own thread" thread
I didn't get the part where I must update my android project for add ad support:
What should I do?
What I did was copy the google-play-services_lib folder into the love_android folder and use the command line, it worked, but when I do a ant debug it shows BUILD FAILED "/../google-play-services_lib resolve to path with no project file for project directory to my love_android project"Adding google-play-services_lib without an IDE
For adding google-play-services_lib to your project you will first need to download it from the android-sdk by going to the "Android Sdk Manager" on "extras" and checking on "Google Play Services" then you can find the library folder on android_sdk/extras/google/google_play_services/libproject/google-play-services_lib. Now you have to paste it next to the project folder and execute "android update project -p 'dir/to/google-play-services_lib' " and you're done!
What should I do?
- bobismijnnaam
- Prole
- Posts: 18
- Joined: Thu Mar 17, 2016 5:18 pm
- Location: Netherlands
- Contact:
Re: "Questions that don't deserve their own thread" thread
Hey everyone, a quick question about forum guidelines. I posted a topic in this subforum (maybe you saw it a minute ago), but I accidentally submitted it twice. Now the second submission one was rejected, so all should be fine (I got a notification). My first submission however also disappeared (deleted?) while I was editing it (wanted to add a download link for a working example of the problem I was asking about). Is this an error related to my double posting? Or was my post in error somehow? I would post the post contents here but if my post was deleted for a specific reason I'd like to make sure it doesn happen again :s I didn't get any private messages about my posts so I'm quite confused.
EDIT:
The post is back, with edit and all! Sorry for the confusion
EDIT:
The post is back, with edit and all! Sorry for the confusion
lc = love.timer -- love.chrono :-)
Re: "Questions that don't deserve their own thread" thread
Hi! Sorry, I'm the one who handled your first topics, I was in a hurry and had no time to properly explain things ^^'
I disapproved one of your posts because, as you said, you posted it twice and could not see it because it needed to be approved. When you edited the approved one the edit needed approval as well, and I approved it. I should have written something before and avoided this situation ^^'
Welcome here anyway!
I disapproved one of your posts because, as you said, you posted it twice and could not see it because it needed to be approved. When you edited the approved one the edit needed approval as well, and I approved it. I should have written something before and avoided this situation ^^'
Welcome here anyway!
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
- bobismijnnaam
- Prole
- Posts: 18
- Joined: Thu Mar 17, 2016 5:18 pm
- Location: Netherlands
- Contact:
Re: "Questions that don't deserve their own thread" thread
Haha wow, that's quite elaborate. Thanks! It seems like a nice place here
lc = love.timer -- love.chrono :-)
Who is online
Users browsing this forum: Bing [Bot] and 5 guests