Author Topic: Random crimes generation?  (Read 562 times)

Offline phpfan

  • Level 3
  • *
  • Posts: 6
  • Reputation: +0/-0
    • View Profile
Random crimes generation?
« on: November 07, 2011, 01:27:28 AM »
Hi,
i'm trying to get started with a small crime game..
Let's say I have a crime where it generates the following outcomes:
1- failure - caught for jail
2- fail, but not caught for jail
3- success

and for success we have the following:
car A - best car
car B - middle range
car C - cheapest/lower range

And all those cars would have x% damage

What mathematical calculation I could use for this scenario. Considering the fact that most of the time outcome 1 and 2 should be obtained more often, while the others on rare occasions (+ may be some success level bonus to be added)

Can anyone help or discuss it further?
I'm not looking for you to write my code, just the approach/logic that needs to be taken..
Thank you.

Offline hiigara

  • Level 12
  • *
  • Posts: 85
  • Reputation: +0/-0
    • View Profile
Re: Random crimes generation?
« Reply #1 on: November 07, 2011, 04:34:35 AM »
No complex calculation is needed. Just generate a random number x between 1 and 100 then:
if x >=1 and x <=40 then caught for jail
...
etc

Offline phpfan

  • Level 3
  • *
  • Posts: 6
  • Reputation: +0/-0
    • View Profile
Re: Random crimes generation?
« Reply #2 on: November 07, 2011, 06:29:41 AM »
No complex calculation is needed. Just generate a random number x between 1 and 100 then:
if x >=1 and x <=40 then caught for jail
...
etc

Assigning each with a range, yes seems a good approach.. except that the rand should be 'near random' and not generating a common pattern.

Thanks for your reply hiigara, appreciate it!

Offline phpfan

  • Level 3
  • *
  • Posts: 6
  • Reputation: +0/-0
    • View Profile
Re: Random crimes generation?
« Reply #3 on: November 08, 2011, 01:06:27 AM »
What if a % is linked with each crime. Like as and when you do a crime, the % of success increases..etc
So now the probabilty of obtaining that crime as a success, will also increase and hence be affected by the % also.

How to link that to the above discussed?

Offline saljutin

  • Level 22
  • *
  • Posts: 266
  • Reputation: +6/-0
    • View Profile
Re: Random crimes generation?
« Reply #4 on: November 08, 2011, 01:24:56 PM »
you are doing it wrong :)
it is YOUR game and you need to define "borders". there is no wrong and no right answer. but still I can help :)

1. get your self BASIC intervals - lets say:
1 = 10%
2 = 70%
3 = 20%

if 3 then:
A = 10%
B = 30%
C = 60%

damage:
10 - 50 = 65%
50 - 80 = 25%
80 - 100 = 10%
(when you calculate which group of damage your car is you use random 80-100 so its linear and you do two calculations)

and now you go with STATISTICAL approach.
you need to calculate what is probability that some user will get BEST 100% DURABLE car:
20/100 * 10/100 * 10/100 * 1/20 = 2000/20000000 = 0,0001 = 0,01%
1st number is probability that user will succeed with his crime
2nd number is that he gets best car
3rd number is that that car has 80 - 100 durability
4th number is last random which gives you number from 80 to 100

do such calculations in excel so you can modify all % and you have your BASICS set

then you can go with some skills:
- robbery skill 0 - 100% (bigger chance for crime to be successful)
- mechanical skill 0 - 100% (bigger chance that car is undamaged)
- observation skill 0 - 100% (bigger chance for better car)

lets say "robbery skill":
basics are (when you are 0% skilled robber):
1 = 10%
2 = 70%
3 = 20%
when you are 100% skilled robber:
1 = 5%
2 = 60%
3 = 35%

so:
1 = 10% - x/100*5%
2 = 70% - x/100*10%
3 = 20% + x/100*15%

do that in excel with graphs and fancy shit also so you can SEE things and modify them so they suit your needs :)

IDEA: higher observation skill means bigger chance to get good car BUT also bigger chance to get you in jail if you fail :)

Offline Chris

  • Game Owner
  • Level 35
  • *
  • Posts: 2,217
  • Reputation: +28/-1
    • View Profile
Re: Random crimes generation?
« Reply #5 on: November 08, 2011, 02:53:54 PM »
The calculations are not the problem, the problem is the crimes names. How are going to generate crime names?

To my experience the complexity of making good name generator exceeds the benefit of making the crimes autogenerated. Manually creating these would require less work.

Offline phpfan

  • Level 3
  • *
  • Posts: 6
  • Reputation: +0/-0
    • View Profile
Re: Random crimes generation?
« Reply #6 on: November 09, 2011, 11:05:13 PM »
saljutin:
Thanks for the nice elaboration :)

Chris:
for my example, the crime is already be fixed. In this case I don't really need to bother with a name generator?

I'm not sure if I'm understanding the exact meaning of the 'name generator' as applicable to an online game, but we could just have a dictionary or array of names with indexed keys... so you just have to randomise the keys and then you get the corresponding names?

Offline Chris

  • Game Owner
  • Level 35
  • *
  • Posts: 2,217
  • Reputation: +28/-1
    • View Profile
Re: Random crimes generation?
« Reply #7 on: November 10, 2011, 03:33:54 AM »
If you have a fixed crime already what you need the crime parameters generator for?

I'm not sure I understood what you are trying to code.

Offline AltarofScience

  • Level 12
  • *
  • Posts: 90
  • Reputation: +1/-0
    • View Profile
Re: Random crimes generation?
« Reply #8 on: November 10, 2011, 09:36:08 AM »
he wants to write some code to generate the results of the crimes. he doesnt want to generate different crimes themselves. i believe saljutin game him the information he wanted.

Offline Chris

  • Game Owner
  • Level 35
  • *
  • Posts: 2,217
  • Reputation: +28/-1
    • View Profile
Re: Random crimes generation?
« Reply #9 on: November 10, 2011, 11:03:04 AM »
Oh, now it makes sense :)


Make two basic parameters, crime difficulty and crime theme. Difficulty determine the, well, difficulty :) and theme determine what you need for it to succed.

function crime($dif,$theme)
{
$failchance=rand(1,$dif);

if($theme=='bank') if(!$safeopenskill) $failchance*=2;
if($theme=='blackmail') if(!$intimidationskill) $failchance*=2;

return $failchance;
}

Offline phpfan

  • Level 3
  • *
  • Posts: 6
  • Reputation: +0/-0
    • View Profile
Re: Random crimes generation?
« Reply #10 on: November 11, 2011, 07:52:49 PM »
he wants to write some code to generate the results of the crimes. he doesnt want to generate different crimes themselves...

that's exactly what I wanted to convey, thanks :) Except that I am not expecting codes, but the logic discussion ;)

@Chris:
thanks for showing how you would do it. Will see how I can merge all that's been said in here..


Meanwhile, if anyone else has another angle, you are most welcomed to continue this discussion.

Thanks people!

 


SimplePortal 2.3.3 © 2008-2010, SimplePortal