Page 56 of 91
Re: "Questions that don't deserve their own thread" thread
Posted: Wed Mar 16, 2016 10:13 pm
by XxHAMADEHxX
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
Re: "Questions that don't deserve their own thread" thread
Posted: Wed Mar 16, 2016 10:24 pm
by zorg
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]
Re: "Questions that don't deserve their own thread" thread
Posted: Wed Mar 16, 2016 11:11 pm
by XxHAMADEHxX
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
zorg 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.
I see. I think I have to seed for my case because I'm not using love.run
zorg 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]
Oops XD didn't pay attention to that. Thank you friend
Thank you for helping me friends.
Re: "Questions that don't deserve their own thread" thread
Posted: Thu Mar 17, 2016 12:41 am
by Nixola
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.
Re: "Questions that don't deserve their own thread" thread
Posted: Thu Mar 17, 2016 1:58 am
by XxHAMADEHxX
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
You can't be "not using" love.run, it's run by default.
My ignorance is strong
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.
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
Posted: Thu Mar 17, 2016 2:18 am
by s-ol
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.
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.)
Re: "Questions that don't deserve their own thread" thread
Posted: Thu Mar 17, 2016 2:22 am
by Kibita
I didn't get the part where I must update my android project for add ad support:
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 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"
What should I do?
Re: "Questions that don't deserve their own thread" thread
Posted: Thu Mar 17, 2016 6:30 pm
by bobismijnnaam
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
Re: "Questions that don't deserve their own thread" thread
Posted: Thu Mar 17, 2016 6:48 pm
by Nixola
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!
Re: "Questions that don't deserve their own thread" thread
Posted: Thu Mar 17, 2016 6:49 pm
by bobismijnnaam
Haha wow, that's quite elaborate. Thanks! It seems like a nice place here