Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 21 Oct 2009
Offline Last Active Dec 07 2013 02:17 PM

Topics I've Started

AI approach for a Virtual Pet / Tamagotchi-like game

05 November 2012 - 08:37 AM

I am thinking about developing something small but 'intelligent' in free time.
Everybody knows 'Tamagotchi' series, 'Virtual pet' clones and so on - they all share one common thing:

you get an egg from which:
  • your pet borns,
  • then you need to take care of him (turn off the light to force him to sleep, feed him, cure him, play with him)
  • your pet grows
  • and grows
  • and finally dies.
States can be programmed within a single FSM, but what about the pet moving within those states?
What should decide what state the pet is besides the human intervention ( like forcing pet to go to sleep ).

Let's imagine a situation where a pet is born, it gets some default/randomly generated stats.
Now i could easily hardcode something like:

if(m_fHunger > 50) FSM->ChangeState(PetHungryState::Instance())

But that is something i want to avoid.

It can be very easy and predictable like for kids, on the other hand it can be very challenging and 'intelligent' if i choose the right approach from the beggining, and i am targetting the second option here.

I would like it to be unpredictable but intelligent, behaviouristic, AI driven.

So my question to you guys is: what kind of AI approach should i choose / algorithm / technology to make it a small but fascinating project ?
What can be managed by correctly choosen AI and what has to be managed by a code ?

Thanks very much!

AABB-AABB collision normal ( SOLVED )

08 September 2012 - 02:36 PM

Ok, i don't think i will ever invent that so i better ask before spending another days looking for something related to the problem...
SOLUTION FOUND HERE: http://www.gamedev.net/topic/567310-platform-game-collision-detection/

My game uses AABB's for collision detection, and i check objects for collision with:

[source lang="cpp"]int CBoundingBox::classify(const CBoundingBox& rOther){ if( rOther.min.x >= min.x && rOther.max.x <= max.x && rOther.min.y >= min.y && rOther.max.y <= max.y && rOther.min.z >= min.z && rOther.max.z <= max.z ) { return INSIDE; } if( max.x < rOther.min.x || min.x > rOther.max.x ) return OUTSIDE; if( max.y < rOther.min.y || min.y > rOther.max.y ) return OUTSIDE; if( max.z < rOther.min.z || min.z > rOther.max.z ) return OUTSIDE; return INTERSECTS; }CVector3 CBoundingBox::closestPointOn(const CVector3& vPoint){ CVector3 xClosestPoint; xClosestPoint.x = (vPoint.x < min.x)? min.x : (vPoint.x > max.x)? max.x : vPoint.x; xClosestPoint.y = (vPoint.y < min.y)? min.y : (vPoint.y > max.y)? max.y : vPoint.y; xClosestPoint.z = (vPoint.z < min.z)? min.z : (vPoint.z > max.z)? max.z : vPoint.z; return xClosestPoint;}bool CBoundingBox::hasCollided(const CBoundingBox& rOther) const{ if( min.x > rOther.max.x ) return false; if( max.x < rOther.min.x ) return false; if( min.y > rOther.max.y ) return false; if( max.y < rOther.min.y ) return false; if( min.z > rOther.max.z ) return false; if( max.z < rOther.min.z ) return false; return true;}[/source]

That works perfectly fine but i need to implement sliding with AABB's so i will need to find out collision normal between AABB1 colliding with AABB2.

Can somebody *please* help me out with this and show me how do i calculate a collision normal between two AABBs ( the normal of the face of the AABB that the player is colliding with ) / find colliding AABB faces ?

3DSMax: Baking textures #1

07 August 2012 - 04:46 AM

As my iOS engine cooperates with 3DSMax via my custom plugin i would like to ask you guys one thing.

- Can i select all objects in the scene ( having different textures ) and bake their textures into a single one (like atlas) ?

The Game Logic - how do you handle that?

31 July 2012 - 09:42 AM

what are the approaches used to handle the game/level logic, which prevent you from falling into a spaghetti code?

I have a player in 3d isometric adventure game where you escape from a set of rooms.
Each room is different and sometimes you will need to go back, to pickup an item which is needed in your current ara ( you pickup a wrench in room 3, which you will use in room 6 to open up the safe ).

Let's imagine a simple level :

Posted Image


Ok, now that is easy aye?You can make this easily with a single BOOLean like:


bool bHasKey = false;

// Event handler
   if(item == key)
	bHasKey = true;

if(bHasKey == true)

It's easy but i would like to avoid this kind of coding game logic - as it turns very quickly, that if you handle 10 rooms per level in one game state, and you have 5 levels, your game state class for level handling will grow into a piece of if/else/switch/case stuff that you'll debug continously scratching your head and asking - why is this here, and that there..?

Let's go to another theoretical room.
So, this time player has tu pull 3 switches in specific order - which in return opens the door for 5 seconds.

Posted Image


Now this level plus the previous one are slowly moving towards a mess - but as long as there are three to four rooms per level - you can handle it somehow.

What if my Level (map) has 10 rooms, each one more and more complicated, and i have 5 levels ready - making 50 rooms in total.
This kind of coding would be a disaster sooner or later...

How do you approach that ? single state machine per level ? ( how would you apply it to this model ? ) anything else?

I just can't figure out how to do it - my brain is empty after several days of decoding ima4.

Thanks !

Handling level logic ( events ) in the engine.

12 May 2012 - 03:48 AM

I am thinking of a way to handle level logic in the game.

Let's imagine we have a situation like this ( quick drawing )

Posted Image

We have two rooms ( Room1, Room2 ) and Doors.

Player has to go from Room1 to Room2 in order to progress with the game.
To achieve that,

- he has to grab ( collide with ) the key,
- collide with the doors ( what will check if he has the key and if true, doors will open )
- after he goes through the doors to Room2 player hits 'trigger object' ( collides with it ) and doors close - so there is no way you can go back to Room1.

How is this normally handled in small games ?
How is logic handled for levels like the one above and more complicated situations ?

Is it called Event Handling ( http://www.gamedev.net/page/resources/_/technical/game-programming/effective-event-handling-in-c-r2459 ) ?