Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #41  
Old 11-12-2011, 09:51 AM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
Quote:
Originally Posted by Tolnaftate2004 View Post
The example I gave was wrong, unfortunately. I can't edit that post. it should be 1.666...
The number of cars that can fit in a lot of size 4 is 2. No matter where the first car parks, there is always room for the second car.
kewl
__________________
Reply With Quote
  #42  
Old 11-21-2011, 09:26 PM
Tolnaftate2004 Tolnaftate2004 is offline
penguin.
Join Date: Jul 2004
Location: Berkeley, CA
Posts: 534
Tolnaftate2004 is a jewel in the roughTolnaftate2004 is a jewel in the rough
Send a message via AIM to Tolnaftate2004
Alright, this thread has been dead for long enough...

Like I said before, the fact that the lot is circular is important. However, let us consider the first car. With probability 1 it parks somewhere in the lot (since it's empty). Then we can henceforth consider the lot to be linear (and 1 car-length shorter) with one end being the front of the first car and the other the end of the first car. And we have 1 car in our lot. So,

f(N; circular) = 1 + f(N-2; linear).

So now we consider the second car and a lot of N-2. Somewhere in this lot, the car will park and split our lot into 2 even further smaller lots. If we number the units 0 ... N-3, let us call the smaller unit number that the second car occupies i. After parking, there are lots of size i and N-4-i. So,

f(N-2; linear | car 2 parks in unit i) = 1 + f(i; linear) + f(N-4-i; linear).

For those of you who know your probability, you'll know that

P(Y) = P(Y | X = x1) * P(X = x1) + ... + P(Y | X = xn) * P(X = xn).

And for those of you who don't, P is the probability and that | means "given".

So, we apply this rule to the above:

f(N-2; linear) = 1 + (f(0; linear) + f(N-4; linear)) * P(i = 0) + ... + (f(N-4; linear) + f(0; linear)) * P(i = N-3).

Of course, P(i = x) = 1/(N-3), so we can boil this down to

f(N; linear) = 1 + 2/(N-1)*(f(0) + ... f(N-2)).

When applied, f(100; circular) = 43.233235838...

However, the recursion grows with N!! (repeat !s as many times as a car-length... ), so to speed up this calculation, we use memoization.

PHP Code:
function f(n) {
  if (
2) return 0;
  
temp.f.("lot_" n);
  if (
r) return r;
  
temp.0temp.0;
  for (; 
1;)
    
+= f(i++);
  
/ (1) * v;
  
f.("lot_" ) = v;
  return 
v;

I've looked at the case where cars can park at non-integer positions within the lot. The answer would be smaller than the discrete case, so I have a sneaking suspicion that Mark Sir Link got it right in that case (but it's a pretty hard problem to solve exactly). Brownie points for you.
__________________
◕‿‿◕ · pfa · check yer syntax! · src

Killa Be: when i got that locker in 6th grade the only thing in it was a picture of a midget useing a firehose :/

Last edited by Tolnaftate2004; 11-22-2011 at 04:27 AM..
Reply With Quote
  #43  
Old 11-21-2011, 10:20 PM
Tricxta Tricxta is offline
The Muffin Man
Tricxta's Avatar
Join Date: Oct 2010
Location: Australia
Posts: 563
Tricxta is just really niceTricxta is just really nice
Looks more like a maths lesson rather then a programming solution. Pretty cool though since I see what you did there, I'll rep you for that.
Reply With Quote
  #44  
Old 11-21-2011, 10:40 PM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
gj on the four people that entered.
__________________
Reply With Quote
  #45  
Old 11-21-2011, 11:26 PM
oo_jazz_oo oo_jazz_oo is offline
Jazz teh Awesome
oo_jazz_oo's Avatar
Join Date: Jul 2006
Location: California
Posts: 596
oo_jazz_oo is a jewel in the roughoo_jazz_oo is a jewel in the rough
Send a message via MSN to oo_jazz_oo
I'm bad at conceptualizing maths.

Can't we have a programming excercise thats like....useful. :3
__________________

Reply With Quote
  #46  
Old 11-22-2011, 04:26 AM
Tolnaftate2004 Tolnaftate2004 is offline
penguin.
Join Date: Jul 2004
Location: Berkeley, CA
Posts: 534
Tolnaftate2004 is a jewel in the roughTolnaftate2004 is a jewel in the rough
Send a message via AIM to Tolnaftate2004
Quote:
Originally Posted by oo_jazz_oo View Post
... useful
Explain.
__________________
◕‿‿◕ · pfa · check yer syntax! · src

Killa Be: when i got that locker in 6th grade the only thing in it was a picture of a midget useing a firehose :/
Reply With Quote
  #47  
Old 11-22-2011, 08:55 PM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
Quote:
Originally Posted by Tolnaftate2004 View Post
Explain.
I really love you and your knowledge, it's great. (No sarcasm)

but will you ever use this on Graal?
__________________
Reply With Quote
  #48  
Old 11-22-2011, 10:24 PM
Tolnaftate2004 Tolnaftate2004 is offline
penguin.
Join Date: Jul 2004
Location: Berkeley, CA
Posts: 534
Tolnaftate2004 is a jewel in the roughTolnaftate2004 is a jewel in the rough
Send a message via AIM to Tolnaftate2004
Quote:
Originally Posted by xAndrewx View Post
I really love you and your knowledge, it's great. (No sarcasm)

but will you ever use this on Graal?
Probably not to figure out how many cars are parked in my lot, but for something which uses a similar algorithm (e.g. baddy decision making).
__________________
◕‿‿◕ · pfa · check yer syntax! · src

Killa Be: when i got that locker in 6th grade the only thing in it was a picture of a midget useing a firehose :/
Reply With Quote
  #49  
Old 11-22-2011, 11:02 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
I can understand this is to challenge peoples problem-solving skills, but it doesn't seem like many scripters are interested in it because they end up seeming like something you'd see in a math class finals paper.

I think what Jazz was saying was to have the challenges that would relate more to what a scripter would have to do while scripting a server or something. For example scripting a physics movement system for a sidescrolling main character, or perhaps scripting a physics collision system.
Reply With Quote
  #50  
Old 11-22-2011, 11:32 PM
Tolnaftate2004 Tolnaftate2004 is offline
penguin.
Join Date: Jul 2004
Location: Berkeley, CA
Posts: 534
Tolnaftate2004 is a jewel in the roughTolnaftate2004 is a jewel in the rough
Send a message via AIM to Tolnaftate2004
Quote:
Originally Posted by DustyPorViva View Post
I think what Jazz was saying was to have the challenges that would relate more to what a scripter would have to do while scripting a server or something. For example scripting a physics movement system for a sidescrolling main character, or perhaps scripting a physics collision system.
HR tried that, and it was the least-active exercise to date.
__________________
◕‿‿◕ · pfa · check yer syntax! · src

Killa Be: when i got that locker in 6th grade the only thing in it was a picture of a midget useing a firehose :/
Reply With Quote
  #51  
Old 11-22-2011, 11:55 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Quote:
Originally Posted by Tolnaftate2004 View Post
HR tried that, and it was the least-active exercise to date.
Honestly all the exercises seem fairly inactive, it seems wrong to criticize that challenge for it.
Reply With Quote
  #52  
Old 11-23-2011, 12:15 AM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
How the hell are all of you people this good at maths. I wish I was this good. I question the answer when I make RC echo 4 + 4
You make me feel dumb lol. Do any of you have an A level in further maths?
__________________
Reply With Quote
  #53  
Old 11-23-2011, 01:09 AM
Tricxta Tricxta is offline
The Muffin Man
Tricxta's Avatar
Join Date: Oct 2010
Location: Australia
Posts: 563
Tricxta is just really niceTricxta is just really nice
Quote:
Originally Posted by Emera View Post
Do any of you have an A level in further maths?
what do you mean? I know mathematical induction does that count?
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 10:34 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.