The magic of elevators

I must admit that when i started to code an elevator system for a building sim, i thought it would be as easy as max an hour of work.
– Push the button, enter the elevator, exit on your floor.

And in theory, it is very easy, especially when you only have one user of the elevator, and just a couple of floors in your building.

But, this turned out to not be working so well when you have more elevators and a really tall building and 100+ employees to use the elevator.

Scenario
A worker with a high index and a late update (compared to all workers with index below), comes to the elevator and push the button. The elevator is already in use, and thus the worker has to wait.
This goes on almost forever, because workers with lower indexes, who’s also waiting for the elevator will be getting it first since they will always push the button before a worker with higher index, because they have their update methods earlier.

So, what needed to be done was a queue system that records which worker was there first, so that their “button push” will be dealt with in a first in, first out – manner.

But, if there is always the fifo-person to use and order the elevator to a certain floor, then he could be the only passenger at any given time. Ofcourse this is not really effecient, nor user friendly. And it wasnt they way i wanted it to work. More people are supposed to ride it at any given time.

But, this is also supposed to be effecient.
The scenario turned out like this.

  1. Push button, to order the elevator to my floor.
  2. The elevator cart is on my floor, was it because i pushed the button, or is it going to pass me?
  3. If it’s going to pass me, stop and enter the elevator ONLY IF
    – There is a passenger slot free.
    – The elevator is moving in the direction i want to go.
    – The elevators current destination is further or equal to my destination.
  4. If it’s because i pushed the button, enter the elevator.
  5. Wait until the elevator is on my destination floor.
  6. Exit.

And then there is the twist with draw order, when i have multiple elevator carts in the same elevator shaft, but thats another story! =)


Still not happy

.. with the elevator sytem and queue system.

The FIFO kind of system is working the way it should, but im getting the impression that this is not the most effecient system for an elevator. This is becoming very clear when the company has about 100 employees, and everyone wants to go home from work at around 5pm.

Back to the drawing board on this i guess. =/


Working out some bugs

Spent the larger part of the day of straightening out some bugs, ive been dragging with and been annoyed about.

Thing is, when i set out to do this game, i didnt really realise that when doing an office simulator, i actually hade to do AI for all things at the office. This is including a somewhat smart elevator system, and elevator queue system.
This is the thing thats been bugging alot. It didnt properly register when somebody got off the elevator for some reason. And only sometimes.

Now, this is probably the most annoying part for most devs, that something only happens “sometimes”, and its really hard to figure out what the actual scenario is when this happens. But anyways, i figured it out, and im glad thats out of the way.

Still waiting for the last bits and pieces from Murry the designer. Should be able to do a video/trailer in about a week or two!


Artwork from the game

Artwork from the game


Elevators and pathfinding

So far, i’ve taken the easy way of doing things. Among those things are the elevators/transportations.

When i first started out on this game, i was thinking that the infrastructure allowed to be built by the gamer should be very strict, and thus only enabling building blocks to be placed directly on top of another, and the transportations are to be put vertically between building blocks. And therefore the entire building would be a homogenous slab of bricks. But it would also mean that it will be sort of a boring building.

What i really want is that the gamer should be able to create any type of building they want, wether it be a giant homogenous slab of bricks, or a 40 stories twin tower, with alternating horizontal positions of the building blocks.

This would also mean that the elevators/transportations must be limited in height so that they dont overlap a building block

So the game should enable the gamer to put elevators like this:
Elevator 1: Bottomfloor = 1, Topfloor = 5
Elevator 2: Bottomfloor = 4, Topfloor = 15

… instead of as it is now:
Elevator 1: Bottomfloor = 1, Topfloor = 15
Elevator 2: Bottomfloor = 1, Topfloor = 15

This though, opens up for a near total rewrite of the AI of the workers in the building, because then they have to potentially look for more elevators/transportations.

I’ll have to think about this….


So, devblog… okay.

Hey there,

So, first post then. What to write?

Well, how about what is my game about for Dream Build Play 2012?
It’s a tycoon/business simulator sort of game. You’re supposed to build a contact center from the ground up, employing the right type of staff needed to drive your business in the right direction, depending on a couple of parameters.

The game is inspired by other tycoon games, aswell as small flashgames i’ve come across in the past.

All the programming is done by me, and graphic design is done by former Halfbrick Studios artist Murry Lancashire.

Will post some screens later!