Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- io.stdout:setvbuf("no") -- console out put for someline text
- CONTINENT = {}
- SPECIES = {}
- do for u = 1, 8 do SPECIES[u] = {} end end
- TRAITS_DECK = {}
- function autotroph(N)
- -- an autotrophic protist
- SPECIES[N]["cell-type"] = "single-celled"
- SPECIES[N]["aquatic"] = true
- SPECIES[N]["land"] = false
- SPECIES[N]["organism-type"] = "autotroph"
- SPECIES[N]["traits"] = {"protist",[6]="photosynthesis"}
- SPECIES[N]["morphology"] = {"eukaryotic"}
- end
- function setup()
- -- create continent board: 4 resources
- local terrestial = 10
- local aquatic = 10
- local organic = 10
- local inorganic = 10
- -- create species board
- autotroph(1)
- end
- function update_species(N)
- -- find dominant traits
- -- if trait appears more than 4 times, remove it from the species board
- -- add it to the species morphology, add one new trait card to the species
- local traits = {}
- for i = #SPECIES[N]["traits"], 1, -1 do
- local v = SPECIES[N]["traits"][i]
- traits[v] = traits[v] and traits[v] + 1 or 1
- if traits[v] > 4 then
- print("Found Dominant Trait '"..v.."' in Species["..N.."]")
- print"Updating morphology and removing dominant trait..."
- table.insert(SPECIES[N]["morphology"], v)
- for j = #SPECIES[N]["traits"], 1, -1 do
- if SPECIES[N]["traits"][j] == v then
- table.remove(SPECIES[N]["traits"], j)
- end
- end
- end
- end
- end
- function print_species(N)
- for k,v in pairs(SPECIES[N]) do
- if type(v)=="table" then
- for l,b in pairs(v) do
- print(k,v,b)
- end
- else
- print(k,v)
- end
- end
- end
- function love.load()
- setup()
- print_species(1)
- update_species(1)
- print"..."
- SPECIES[1]["traits"][2] = "protist"
- SPECIES[1]["traits"][3] = "protist"
- SPECIES[1]["traits"][4] = "protist"
- SPECIES[1]["traits"][5] = "protist"
- --update_species will see 5 same traits and remove those traits
- --and add it to the morphology
- --haven't implemented adding new traits yet
- --also, should there be a chance to draw a card of the trait just removed?
- update_species(1)
- print_species(1)
- update_turn(1)
- end
- function HasPhotosynthesis(N)
- return not not string.find(table.concat(SPECIES[N]["traits"]),"photosynthesis")
- or not not string.find(table.concat(SPECIES[N]["morphology"]),"photosynthesis")
- end
- local turn_count = 1
- function update_turn(N)
- print(HasPhotosynthesis(N) and "Ate sunlight" or "Did not eat sunlight")
- turn_count=turn_count+1
- print("Another turn has passed")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement