Skip to content

Instantly share code, notes, and snippets.

@ruoyu0088
Created September 24, 2022 09:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ruoyu0088/f5418bd8400c7192f13495e6b70c8185 to your computer and use it in GitHub Desktop.
Save ruoyu0088/f5418bd8400c7192f13495e6b70c8185 to your computer and use it in GitHub Desktop.
import taichi as ti
ti.init(arch=ti.gpu)
StatusSearch, StatusAtFood, StatusGoHome, StatusAtHome = 1, 2, 3, 4
pi = 3.1415926
width = 80
height = 60
N = 1000
ant_length = 1
ants_pos = ti.Vector.field(2, ti.f32, N)
ants_head = ti.Vector.field(2, ti.f32, N)
ants_angle = ti.field(ti.f32, N)
ants_status = ti.field(ti.i32, N)
ants_food_chemical = ti.field(ti.f32, N)
ants_home_chemical = ti.field(ti.f32, N)
ants_clock = ti.field(ti.f32, N)
home_chemical = ti.field(ti.f32, (width, height))
home_chemical2 = ti.field(ti.f32, (width, height))
food_chemical = ti.field(ti.f32, (width, height))
food_chemical2 = ti.field(ti.f32, (width, height))
home = ti.field(ti.i32, (width, height))
food = ti.field(ti.f32, (width, height))
background = ti.Vector.field(3, ti.f32, (width, height))
line_begin = ti.Vector.field(2, ti.f32, N)
line_end = ti.Vector.field(2, ti.f32, N)
image_flag = 0
gui = ti.GUI('Ants', (width, height))
while gui.running:
gui.clear()
gui.set_image(background)
#gui.lines(line_begin.to_numpy(), line_end.to_numpy())
gui.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment