Tangle Farm

app data
version: v0.1
compatibility: ql-0.3
author: microhash
released: July 2018
description: »Grow and harvest food on your own farm. The first qApp and decentralized IOTA game. The game state is entirely stored on the Tangle and validated by Qubic Lite.«
ingame screenshot (Qlite Web)

install the app

if you haven't set up your QLRI yet, start here.

via Qlite Web
1
2
3
from the QLRI terminal
1
2
3

ql code

by using this code you can host this game yourself with an own qubic. let each player create an iam stream via qlite web and simply adjust the first line of the code so it contains exactly their iam stream ids.

accs = ['DWDZMAOXQNIUORJESVFGD9RPISHJEICVLFHMFJ9LFQREXELZPDKBWFSEEMIGVDVWRSFKOKEXILSYZX999', 'HCRPNTMSEHIOHRPPJQWHKH9FLQITOKVKIFWHSPYCJEMQBJYHLENJU9YQCBMZ9SLKXAZHGHGPMPAHJX999'];

H = 10;
W = 15;
TIMES = [10,14,20,30,40,60,80,120,160,300];

if(epoch < size_of(accs)) {
  map = []; age = [];
  y = 0; while(y < H) { map[y] = []; age[y] = []; x = 0; while(x < W) {
    map[y][x] = 0;
    age[y][x] = epoch;
  x++; } y++; }

  return({
    'map':map,
    'age':age,
    'inv':[1,1,1,1,1,1,1,1,1,1],
    'msg':'account created'
  });
}

e = 0; while(!ls) {
e+=size_of(accs);
ls = qubic_fetch(qubic, epoch-e);
}

map = ls['map'];
age = ls['age'];
inv = ls['inv'];

bm = map;
ba = age;
bi = inv;

a = iam_read(accs[epoch%size_of(accs)], epoch);
if(!a) { return({'map':bm,'age':ba,'inv':bi,'msg':'no action'}); }

y = 0; while(y < H) { x = 0; while(x < W) {
  if(a['age'][y][x] == -1) {
    if(map[y][x] > 0) {
      if(epoch-age[y][x] < TIMES[map[y][x]-1]) {
        return({'map':bm,'age':ba,'inv':bi,'msg':'invalid harvest/plant'});
      } else {
        inv[map[y][x]-1]+=2;
      }
    }
    seed = a['map'][y][x];
    if(seed>size_of(inv)) {
      return({'map':bm,'age':ba,'inv':bi,'msg':'unknown plant'});
    }
    if(seed>0) {
      inv[seed-1]--;
    }
    map[y][x] = a['map'][y][x];
    age[y][x] = epoch-1;
  }
x++; } y++; }

i = 0; while(i < size_of(inv)) {
  if(inv[i]<0) { return({'map':bm,'age':ba,'inv':bi,'msg':'insufficient seeds'}); }
i++; }

return({'map':map,'age':age,'inv':inv,'msg':'user input accepted'});

→ copy