naming a company

Discuss the new AI features ("NoAI") introduced into OpenTTD 0.7, allowing you to implement custom AIs, and the new Game Scripts available in OpenTTD 1.2 and higher.

Moderator: OpenTTD Developers

User avatar
Xander
Route Supervisor
Route Supervisor
Posts: 485
Joined: 18 May 2007 12:47
Location: Oxford
Contact:

Re: naming a company

Post by Xander »

Dustin wrote:
Xander wrote: You only need to grow these arrays to a few items each (4 * 4 will do) to never have a naming clash again :)
yack yack yack academic theory yack
Run the code. Academically I can see your point, but in reality this is not even remotely an issue. JAMI doesn't have a problem and uses an almost identical algorithm (she uses a 3*3*3) :P
Real Tycoons do it on Trains!

JAMI: Just Another Moronic Intelligence
User avatar
Dustin
Transport Coordinator
Transport Coordinator
Posts: 272
Joined: 07 Dec 2005 19:22

Re: naming a company

Post by Dustin »

Xander wrote:
Dustin wrote:
Xander wrote: You only need to grow these arrays to a few items each (4 * 4 will do) to never have a naming clash again :)
yack yack yack academic theory yack
Run the code. Academically I can see your point, but in reality this is not even remotely an issue. JAMI doesn't have a problem and uses an almost identical algorithm (she uses a 3*3*3) :P
LOL.

It's not as Academic as you might think. My undergrad work in in psychology and communication, so I don't know most of the academic stuff other programmers do. What I do know is that code exactly like you describe can become a horrible performance bottleneck in the right circumstance and it's very anti-intuitive that this is so.
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: naming a company

Post by Zuu »

With 3*3*3 you have 3^3 = 27 possibilities. And with maximum 15 companies, that is not much of a problem. As even when you pick the 15:th name you have a possibility of (27-14)/27 = 0.48 of picking a valid name. This is a very high possibility considering the computer power we have available.

But if you only have 16 possibilities the probability when picking the name for the 15th company becomes (16-14)/16 = 0.125, which is still high enough that it will not be a practical problem in our case.

But there are cases when the probability of getting it becomes so low that given the time constraints you have it becomes a problem to choose by random until you find something that works. If you want to dig into this you can read on the RSA-algorithm. :-)
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 8 guests