Saving movement/path to database - path

I am creating a football simulation game and I would like to make a 2D view of match. My match is 90 minutes long and there are 22 players on the field. How could I save a movements/path for players so that it wouldn't take lots of space. I know I could save it something like
Minute: min,
Player: id,
X: xCoord,
Y: yCoord
and then just move objects with jQuery from point A to point B, but I am sure it isn't the best solution, because it would require lots of space and database entries.
I am using MongoDB, but all suggestions are welcome.

How do the players move? They move a little in each step of the main loop? Or they go in long straight lines and then make sudden turns and go in other straight lines? In the first case you would probably need to save each milisecond or so (each step of the main loop), or you could save their positions every ten steps or every second, etc. And the replay could interpolate the saved points (thought the replay would look "gross" like that, it could save a lot of space in your db). In the second case (straight lines), you could just save the points where the players turn in another direction. In this case you'll save their position, angle and speed (along with time, obviously).
The first table could be (the intervals could be more than 1ms, depending on the power of the machine):
PLAYER TIME(ms) X Y
1 0 0 0
1 1 0 2
1 2 0 4
1 3 0 7
1 4 0 10
1 5 4 13
While the second table would be:
PLAYER TIME(ms) X Y Dir Speed
1 0 0 0 90 2
1 2 0 4 90 3
1 4 0 10 60 5
or something like that. Dir is the direction in degrees. Hope that helps!

Related

Jump by percentages (10%, 20%, 30%...) in MPV player, like on YouTube?

I'd like to reproduce this behavior:
Pressing the number keys 1-9 would automatically skip ahead in the current video to the corresponding percentage of time. So pressing "4" would jump to the 40% mark of the video, regardless of specific time length of the video. Basically similar to how this works on YouTube.
It seems there's no built-in method for this (and number keys are already assigned other tasks by default) but is there any sort of Lua Script that could achieve this?
Thank you
It was more simple than I anticipated. There is already a percentage command native to MPV. So to produce the desired behavior, I just added this to my input.conf file:
1 seek 10 absolute-percent
2 seek 20 absolute-percent
3 seek 30 absolute-percent
4 seek 40 absolute-percent
5 seek 50 absolute-percent
6 seek 60 absolute-percent
7 seek 70 absolute-percent
8 seek 80 absolute-percent
9 seek 90 absolute-percent

paired duos data with exclosure cages

( I'm French sorry if English bad)
I need help on how treat my data. Tell me if its not the good place to ask that
For 12 weeks I have followed grass height for 4 grassland (ABCD). With 1 measurement per week per grassland.
In each grassland, I have placed an exclosure cage so animals cannot eat grass.
for each grassland :
A : 9 exlcosure cages
B : 6 exlcosure cages
C : 6 exlcosure cages
D : 8 exlcosure cages
measurements were done like this:
Once a Week
5 measurements per exclosure (each corner and middle) AND 5 measurements 10 meter in west (each corner and middle of an imaginary square)
SO each exclosore is paired with an imaginary corner where grass can be eaten.
so in total for exemple on grassland A :
65 mesurement on exclosure AND 65 on correspondant imaginary square
for 12 weeks
Here is the stat question: does the grass in exclosure is higher than in the imaginary square? ( I want to see if red deer uses my grassland, then determine which one are the best nor with places are most used in the grassland)
thanks
tell me if I need to do something to be more precise

Animation in LOGO

I have created a nice pattern using the following one line code
repeat 36 [repeat 10[fd 10 rt 36] rt 10]
Now I want this to appear as if it is rotating. I have tried to clear the screen and then rotate the turtle a at a specific angle and then print the pattern again. But there is something completely wrong in my logic. Can anybody help?
In order to accomplish animation, you need an interpreter which supports it. The interpreter must be one which renders the entire output before displaying it (doesn't show the turtle movement during drawing), and it also must support the wait command (or something similar to it). An example of an interpreter that meets these qualifications would be the one at www.logointerpreter.com. Here's an example which spins your wheel a full rotation and works with that interpreter:
ht
repeat 360
[
clean
repeat 36 [repeat 10[fd 10 rt 36] rt 10]
wait 10
rt 1
]
As you can see, the outer loop draws 360 separate frames. After drawing each frame, it waits 10 milliseconds, so you can see the frame. It then rotates the turtle one degree before clearing the screen and beginning the drawing of the next frame. If you need a little more control, you could also store the starting angle for each frame in a variable, like this:
ht
make "start 0
repeat 360
[
cs
rt :start
repeat 36 [repeat 10[fd 10 rt 36] rt 10]
wait 10
make "start (:start + 1)
]

How to get updated positions in Lua

I have 2 classes, In one class, I have code for position of object1 changing with time and in class2, I have code for object2 changing with time, the positions are changing continuously at different rates. Now, I want to figure out if the two objects collide, but how do I get their positions that are changing at difference of less tahn a second, is their any shortcut or efficient method to do that?
Here is how object1 and object 2 are changing their positions:
object 1:
self:setRotation( self:getRotation() + math.random(5,7) )
object2:
x = 215 + math.cos(angle)*195
y = 130 + math.sin(angle)*115
Both of these are part of 2 different classes. I need to use them in a third lua file where I am checking for the collisions, so how can I get x and y value of both of these as soon as it changes and pass them to a new function to check for collisions
I have 2 classes, In one class, I have code for position of object1 changing with time and in class2, I have code for object2 changing with time, the positions are changing continuously at different rates. Now, I want to figure out if the two objects collide, but how do I get their positions that are changing at difference of less tahn a second, is their any shortcut or efficient method to do that?
Here is how object1 and object 2 are changing their positions:
object 1:
self:setRotation( self:getRotation() + math.random(5,7) )
object2:
x = 215 + math.cos(angle)*195
y = 130 + math.sin(angle)*115
Both of these are part of 2 different classes. I need to use them in a third lua file where I am checking for the collisions, so how can I get x and y value of both of these as soon as it changes and pass them to a new function to check for collisions
Here is how I tried to use Collision detection using TNT
--> let's say I group all my 3 clock hands, these are rotated around an anchor point so x and y remain the same, but they have some width extending,
--> My player is moving in an ellipsis and it's position is changing with time(only when the player jumps, it's not on floor)
Requirement--> what I really want is whenever the player touches any of the clock hands, youLoose method(not given in the code) shall be called, now to achieve this, here is what I did:
and the collision can be anywhere across the length of any of the clock hands,(so basically this part is what I am not getting)
I checked collision as soon as x and y of player changed,here is the code:
attaching the image as well
x = 215 + math.cos(angle)*195
y = 130 + math.sin(angle)*115
for i = 1, groupA:getNumChildren() do
local sprite2 = groupA:getChildAt(i)
local oBoxToObox = tntCollision.oBoxToObox
if i == 1 then
a = 97
b = 11
elseif i == 2 then
a = 206
b = 64
else
a = 120
b = 10
end
local pointToObox = tntCollision.pointToObox
tntCollision.setCollisionAnchorPoint(0, 0)
if oBoxToObox(x,y, 36, 40, cute.anim[self.frame]: getRotation(),sprite2:getX(), sprite2:getY(), a ,b, sprite2:getRotation()) then
youLoose()
end
end
If the objects have volume you need to test if their boundaries cross, quite complicated, and you should use either Box2d or TNT Collision. Both integrated to Gideros (although TNT is a separate download). TNT Collision is only collision, no physics, so likely to be faster but not necessarily so, you would have to compare.
Otherwise (no volume, ie just point collisions), you can just test the x coordinate of each object; if almost identical, then check the y coord; if almost identical you have a collision, otherwise you don't.

what are the values in haarcascade frontalface .xml

in opencv frontalface cascade .xml file what are tree node threshold and left value
such as
3 7 14 4 -1. rect
3 9 14 2 2. rect
4.0141958743333817e-003 threshold
0.0337941907346249 left value
0.8378106951713562 right value
If u know what these values are represent plese give me solution
i assume following please correct me if i am wrong
1) there are 21 stage each stage contain weak classifier
2)3 7 14 -1 represent the rectangle where 3 and 7 (are corodinates of pixel that we need to sum for bright area )14 width and 4 height of image amd multiple that sumt with -1 (weight)
3)3 9 14 2 2 2 is a rect similar to above for dark area and calculate sum and multiple it with weight
4) now make the substraction from values in step (2) and (3) if sutraction < threshold then add left value else add right value
si=milarly for all feature in that stage now add all values from all feature if it is less than stage thershold then go for next stage else reject that area for detection
(5)up to how much stage i need to pass to confirm that it is a face is all
4.0141958743333817e-003 threshold what is reperesnt either the complete exponential value
or threshold range in between 4.0141958743333817e 3
please correct me if i am wrong
thanks in advance

Resources