Pixel City - Driving skills and cop-robber interaction added! (1.0.1)

http://www.youtube.com/watch?v=cei8QTQQC4Q


Tell me what you think of it so far :smiley:

Going to start with the city generator now so inputs, suggestions

and tips on that are more than welcomed :smiley:

cool game so far,

please make your npc system better than oblivion.

Each npc has a predefined personality (in a script file), and many modifiers.

  1. Waypoints : places he likes to visit depending on world time, as well as action he wants to do there.
  2. action modifiers : angry, in love, sad, happy, depressed, hungry, needs water, needs funs, is Taking Damage,



    Actions cause modifiers to others (with your scripting language).
  3. float variables like in sims : hapiness, fun, sleepiness, needs to pee, that can cause modifiers.



    Now with this system npcs would do the same predefined things each day.



    You want them to alter the world based on a Random quest/event generator, e.g

    the blacksmith’s son dies → he is depressed → he stops producing equipment → the villagers have no weapons to defend → the goblin scouts detect the village weakness → the goblins attack.

    [unexpected-to avoid predictability in events]

    It turns out it was a fake death gambit produced by the son staging his death in order to force the goblins to attack the village. He didnt notify the others to make it more believable. blablabla

    Possible scenarios:

    a) the son was in a goblin alliance.

    b) the son waits for everyone to die to keep the loot.

    c) the son ninja loots everything from goblin village since goblins have left it undefended (they went to war).

    d) The son wanted to make war with the goblins but the elders disagreed saying that they have to be peacefull. He worked hard overproducing weapons secretly as well as gathering forces from other villages to defeat the goblins once and for all, if they ever attacked the village. His alliance to the goblins was a double crossing fake betrayal in order to spy on them and gather information.

LOL the subtitle and the West style shooting scene at the end.



Anyway, as I saw in the video , I guess your game stand on a Rule-Base system.



[java]If (rule1) then (do action 1)

else if (rule2) then (do action 2);[/java]



Why you use Java for the job? Why don’t you use Scripting…



Now let’s make one example like in the video : The robber rob the car!



[java]If (robber.find(an expensive prop).ofWho().distance(robber,bigger,10)==true) robber.rob();

[/java]

Let’s consider the complicate code line I typed above:

  1. robber.find(an expensive props) will return a prop
  2. the prop.ofWho() return its owner (victim)
  3. the victim.distance(robber,10) return true or false when the distance between victim and robber > 10.
  4. in robber object which save the last expensive prop he has found, then the system tell him rob the prop.



    It’s how power of scripting is…

    One line - One rule!



    My thought: But when your world is too complex, when the rule condition is ā€œconflictā€ and ā€œconfusingā€ with each other, you have to make a system to decide the right things by pattern matching.



    Take a look at :

    http://en.wikipedia.org/wiki/Rete_algorithm <= I think you 've already known it. But as I see you are ā€œsuper goodā€ at this area, hope that you make it work in java and JME somehow!

P/s: After took a better look at your video , I guessed you use ā€œsteering behaviors systemā€. Or the two guesses are both wrong?

@tralala I’m not going that complex with the personalities myself.

Consider a population of 200 people. I dont need them to calculate whether to be happy or sad by some advance calculation, they will all die by the giant godzilla that’s entering town :stuck_out_tongue:

This game is made to be an engine, foundation, for people to build games of. So creating complex ai’s will be fully supported tho.



@atomix I’m trying to make it easy to write a person without having to script it.

For example, the robbers Soul txt file is here:


Walking:100
Sleeping:50
Running:10
Scout:25



Handgun



HotSpot:Panic




RobberChat




Skin:Robber.png


Then I still had to special write a couple of Ears for him. But that was sort of like your design:
[java]public void recive(Person speaker, String msg, boolean shout) {
System.out.println("Recived: "+speaker.getTitle()+" ("+shout+"): " + msg);
if (speaker.getTitle().equals("Cop")){
if (msg.equals("Hey!")){

p.getMemory().add(speaker, "Hunter");
p.getBrain().forceWakeup();
p.getBrain().setMode("RobberRunAwayFrom");
}
}
}[/java]


Then I have a bounch of Activities that you do. So the mode RobberRunAwayFrom will create a new instance of the activity RobberRunAwayFrom and there is the complex instructions on what to do to avoid cops :P
Finding and Driving a car is also just a set of actions executed in a wished order. FindVehicle, EnterVehicle, DriveCar, LeaveVehicle.

Trying to keep it all very simple to make it easy to modd. When I'm done, to create a high complex character, all you got to do is write a simple soul file of maybe 50 lines. Then extends a Brain and script in there the rest. And that would not be a too big script either as the Activities would do moste of the script job for you. Brains only handles conditions, inputs etc.

Ah, it’s quite a simulation of the real world … Since everyone must ā€œlistenā€ to everything others say! It’s annoying of course but in the term of programming, it’s not just annoying, if we didn’t take good care of it, it will become a bad design IMO.



In still surprise that you manage your code too good. As those code can easily break and out of track sometimes i’m afraid. Please don’t consider this is an offensive argument, I just try to tell something and hope that help:



Assume that 2 things happen : An explosion and one man got killed.

  1. An explosion :

    System tell everyone , there is an explosion. Everyone run by their instinct. The police and the robber have special skill : the police come near to the crime scene, and the robber try to leave the place where he made the explosion.


  2. One man got killed:

    System tell the police that someone killed a normal man. The police come and try to determine who is he?



    As you see in my example, ā€œthe policeā€ which are a ā€œnormal manā€ in the ā€œeveryday lifeā€ (normal situation), extends ā€œnormal manā€ but has an opposite decision when it come to ā€œspecial situationā€.



    May be you know this is the basic concept of an agent system or entity system…



    System has an ā€œevent busā€ which decide to send what event to who…

    And ā€œthe policeā€ is a service, which can be call if need…



    May be when your game grow big, you should consider make one, to keep your code clean and easy to tweak…
1 Like

Very intressting indeed atomix.

So far, if there’s an explosion people will react as written in their souls.

For example, civilians have:



HotSpot:Panic



Explosion events extends HotSpot so therefore, civilians always panic when theres an explosion.

Unless you would override explosions:



HotSpot:Panic

Explosions:Investigate



Then they would panic normaly, but if the event is an explosion then they will investigate.

This is sort of what cops do. But I havn’t scripted the investigation part.



But what I liked about your thinking is the system!

Instead of having each and everyone figuring out whats going on and what to do, the system investigates it!

So instead of having 10 cops doing same logic loop, Ill run the loop once and then cops can get their actions from the investigation!

Thanks, that is truely a great addition to my game which I shall implement.



As for the clean coding, I know, that is on the top priority always.

Atm I’v done 3200 lines of code, I still am not confused about any part.

Got 64 diffrent java files whereas 25 extends or implements other handmade scripts to stay effective.

Trying to keep it clean as much as I can, but it’s a tough job as I think around 3000 lines are my maximum limit before.

Hey Addez, your game/city sim looks awesome :), really love the humour in it :stuck_out_tongue:



Since I“m doing some research for my own future project on topics that seams related to your game, I thought I“ld mention a few things that have cought my attention:

-Entity/component systems (http://cowboyprogramming.com/2007/01/05/evolve-your-heirachy/)

-Steering behaviours (http://www.red3d.com/cwr/steer/)

Hehe, cool. The people doesn’t fly when the car collide with them xD. The driver guy is always suicidal muahUHAUhuAHUA. Very nice.

so if i understand from those papers :



a) delegation everywhere in main engine.

b) In xml files containing the data use inheritance. [avoids data duplication].

Guard

{

extends = civilian

onExplotion(){ investigate();}

}



[ we avoided copy pasting civilian ]


  1. would using multiple inheritance help in data files ? [dupplicate variables are resolved depending on declaration order]


  2. i read about dugeon siedge game objects but i didnt understand it when it suggested that the object’s data be ā€œinterpretedā€ based on a schema, how would that help ? (apart from automatic handling from the game editor).