Technical Implementation: Difference between revisions

From DominAnt
No edit summary
No edit summary
Line 1: Line 1:
'''Just some comments to myself:'''
'''Warning: Things on this page may be wrong! (not up to date)'''


'''Things on this page may be wrong!'''
= Calculations done (on colonies) =
== Every other minute ==
For now calculations take place every other minute. r_nnn below is the ratio on that order setting. Using a linear model. This makes one colony "slow to turn" but by using many colonies it gets done faster. Use ar_worker=worker/(worker+warrior) in some formulas instead of r_worker to reflect the actual population.
* capacity += r_expand * ar_worker * const
* secret capacity += r_expand * ar_worker * r_secret * const  (NOTE: secret is a part of the capacity)
* workers += if (worker+warrior < capacity) r_breed * r_worker * const
* warriors += if (worker+warrior < capacity) r_breed * r_warrior * const
* food += min(capacity, (r_food * ar_worker - level) * (workers+warriors) * const), Gathering and eating, if r_food*ar_worker kept at level or above the food increase, else it decreases. Testing with level = 0.4. NOTE: Food can be negative, to affect how many dies in steps below.


Transform workers to warriors and vice versa
* if (to many warriors compared to workers) warriors -= const, worker +=const , i.e. if ar_worker > r_worker + 0.01
* if (to many workers compared to warriors) warriors += const, worker -=const , i.e. if ar_worker < r_worker - 0.01


* Server controls what is on the map (the client shall not assume anything)
Starving:
* if (food < 0) workers += food*ar_workers, warriors += food*(1-ar_workers)
* if (workers + warriors < 2) colony is dead


== Internal actions ==
Decaying.
* Show Map
* food turn bad, slowly decreases? -= const similar to setting 1%?
* Show Map at pos x,y
Decaying both inhabited and not inhabited
* Show Map at nest n
* if (capacity > 10 or not inhabited) capacity slowly decreases -= const similar to setting 1%?
* Help about n (predefined constants in app) - or use the wiki pages?
* if (capacity < 2 and not inhabited) nest is broken and destroyed
* Show spieces chat with prepared message/location x,y


etc
== Every 12 minutes ==
* Animals at colonies eat and destroy


== Determine water vs land ==
= Network =
http://stackoverflow.com/questions/3645649/i-need-to-know-the-predefined-point-is-in-the-sea-or-on-the-land
 
That pixel or one next to it just to bu sure?
* Server controls what is on the map (the client shall not assume anything)


== Client ==
== Client ==
Line 34: Line 46:


* Notification from server if nearby actions take place, the notifications shall contain enough data to update the info in the client (typically attacks)
* Notification from server if nearby actions take place, the notifications shall contain enough data to update the info in the client (typically attacks)
= Occurance of things =


== Animals ==
== Animals ==
* Amout of animals: Linear to the number of active players.
* Amount of animals: Is currently linear to the number of colonies
* Have a an (average) lifetime and disappears after that time (no matter if in inventory or on ground)
* Have a an (average) lifetime and disappears after that time (no matter if in inventory or on ground)
* Show up nearby users, or on locations where users have been.
* Show up on colonies with notification to owners
* Notifications to nearby users (with setting)


== Food ==
== Food ==
Line 53: Line 66:
** After som time food disappear at the current location and get new distribution, with overlap. TODO HOW?)
** After som time food disappear at the current location and get new distribution, with overlap. TODO HOW?)
** There are fixed areas where the food appear. Over time the internal pos and location is changed. Two overlapping formulas or just one and a fix time when it is changed to the new. Once a week the removed resources are reset and the new ones appear?
** There are fixed areas where the food appear. Over time the internal pos and location is changed. Two overlapping formulas or just one and a fix time when it is changed to the new. Once a week the removed resources are reset and the new ones appear?
== DB ==
* nest - about nests and the  potentially colony living there
* nest_distance - actual distance between nearby nests
* country - move the strings here and store a pointer in the nest-table
* sub country location - move the strings here and store a pointer in the nest-table
* items on the map
** animals - location
** food (generated)
** swarms
* user - basic user data
* user_unit - about each unit connected for each player (needed for notifications)
* user_location - track user location, once per hour or so to be able to spawn creatures at resonable locations, and prevent cheating.
* user_inventory - in some way....
* user_visible_area - in order to know what updates to send to what clients, in some way...
* log - what happened and when. (id ref to types of actions)
* log_user - what event are useful for what user
* historical scores, statistics, log of scores... or something..., even if it all may be calculated by replaying the log.... to be able the get graphs etc. A parts of nest dump every 25h or so...
** This means that nests may not be deleted from the table, just "inactivated" when destroyed.
** animals_log/history - what they did... some how. Needed?
** log what users did and log what animals did
* chat - todo

Revision as of 09:48, 29 April 2016

Warning: Things on this page may be wrong! (not up to date)

Calculations done (on colonies)

Every other minute

For now calculations take place every other minute. r_nnn below is the ratio on that order setting. Using a linear model. This makes one colony "slow to turn" but by using many colonies it gets done faster. Use ar_worker=worker/(worker+warrior) in some formulas instead of r_worker to reflect the actual population.

  • capacity += r_expand * ar_worker * const
  • secret capacity += r_expand * ar_worker * r_secret * const (NOTE: secret is a part of the capacity)
  • workers += if (worker+warrior < capacity) r_breed * r_worker * const
  • warriors += if (worker+warrior < capacity) r_breed * r_warrior * const
  • food += min(capacity, (r_food * ar_worker - level) * (workers+warriors) * const), Gathering and eating, if r_food*ar_worker kept at level or above the food increase, else it decreases. Testing with level = 0.4. NOTE: Food can be negative, to affect how many dies in steps below.

Transform workers to warriors and vice versa

  • if (to many warriors compared to workers) warriors -= const, worker +=const , i.e. if ar_worker > r_worker + 0.01
  • if (to many workers compared to warriors) warriors += const, worker -=const , i.e. if ar_worker < r_worker - 0.01

Starving:

  • if (food < 0) workers += food*ar_workers, warriors += food*(1-ar_workers)
  • if (workers + warriors < 2) colony is dead

Decaying.

  • food turn bad, slowly decreases? -= const similar to setting 1%?

Decaying both inhabited and not inhabited

  • if (capacity > 10 or not inhabited) capacity slowly decreases -= const similar to setting 1%?
  • if (capacity < 2 and not inhabited) nest is broken and destroyed

Every 12 minutes

  • Animals at colonies eat and destroy

Network

  • Server controls what is on the map (the client shall not assume anything)

Client

  • Will have a service (or similar) run once per hour, or so, sending position (web or gcm). The pos is passivly get. I.e. if there is one, read it.

Client <-> Server

  • All actions are asynchronous
  • Send all waiting actions (in client) to one server script using a background thread.
    • The client application holds a list of actions waiting to be performed (with a generated serial id)
    • A json-list with actions
    • All actions have a serial number (unique to user and say 5 min?) and info on what to perform
    • If the action already took place (serial number) just send the updated info (for that action)
    • The server responds with apropriate data on all actions or error messages and also a part with new data (that might have been changed)
    • The client updates data and remove confirmed actions from the list of waiting actions
    • The client sends a new request with waiting actions (including those who where not confirmed)
  • Notification from server if nearby actions take place, the notifications shall contain enough data to update the info in the client (typically attacks)

Occurance of things

Animals

  • Amount of animals: Is currently linear to the number of colonies
  • Have a an (average) lifetime and disappears after that time (no matter if in inventory or on ground)
  • Show up on colonies with notification to owners

Food

  • Pretty evenly distibuted on earth
  • Only visible on zoomed in.
  • TODO Decrease and disappear after some time? New show up. How?
  • When looking at area x1,x1 -> x2,y2, maybe it "scans the lines" and the distance to the next food occurrence is relative to the latitude to get it evenly distibuted. (instead of checking a square pattern)
  • TODO But how to figure out where to spawn more food and where has it already been done?
  • Math pattern having a fixed amount of food and a table with the removed ones (and dropped) and let the patters slowly slide/change in some way...
  • Where is it calculated?
    • One table with lat L,LL and long L,LL values showing where it has been added
    • One table with actual food items on the map. When picked up, they respawn efter some time, or grow up again.
    • After som time food disappear at the current location and get new distribution, with overlap. TODO HOW?)
    • There are fixed areas where the food appear. Over time the internal pos and location is changed. Two overlapping formulas or just one and a fix time when it is changed to the new. Once a week the removed resources are reset and the new ones appear?