Skip to content

GAMA integrate with Python ? #375

Answered by lesquoyb
Thinhvip9999 asked this question in Q&A
Discussion options

You must be logged in to vote

Hello, this is a bit tricky to do for a beginner so I provided an example here:

/**
* Name: main
* Based on the internal empty template. 
* Author: baptiste
* Tags: 
*/


model main

global{
	
	file my_file <- csv_file('../includes/grid_state.csv', ',');
	
	init {
		matrix<int> data <- matrix<int>(my_file);
		loop x from: 0 to:data.columns-1 {
			loop y from:0 to:data.rows-1 {
				my_grid[x, y].value <- data[x,y];
				switch data[x, y] {
					match 0 {
						my_grid[x, y].color <- #white;				
					}
					match -1 {
						my_grid[x, y].color <- #black;
					}
					match 1 {
						my_grid[x, y].color <- #blue;
					}
				}
			}
		}
	}
}

grid my_grid width:40 height:40{
	
	int value;

}

ex…

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@Thinhvip9999
Comment options

@Thinhvip9999
Comment options

@Thinhvip9999
Comment options

@lesquoyb
Comment options

Answer selected by Thinhvip9999
@Thinhvip9999
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants