aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO.md5
-rwxr-xr-xplugins/grapher.py43
-rwxr-xr-xplugins/imager.py46
-rw-r--r--tsalis/include/printer.h2
-rw-r--r--tsalis/src/handler.c8
-rw-r--r--tsalis/src/printer.c67
6 files changed, 104 insertions, 67 deletions
diff --git a/TODO.md b/TODO.md
index f79d1cd..29fd706 100644
--- a/TODO.md
+++ b/TODO.md
@@ -1,10 +1,10 @@
## SALIS UPDATES
-- Add eat-string (EATS) instruction
+- Add eat-string (EATF/EATB) instruction
- Reward organisms for "eating" information
## TSALIS UPDATES
+- Better CLI arguments
- Create process cursor selector (on WORLD and PROCESS view)
-- Enable fast scrolling (on WORLD and PROCESS view)
- Better console:
- Console resumes sim after closing
- Allow longer input
@@ -16,7 +16,6 @@
## PYTHON PLUGINS/APPS
- Create REPORT app that reads many savefiles and generates data files from:
- - Organism count
- Organism sizes
- Instruction count
- Species dictionary
diff --git a/plugins/grapher.py b/plugins/grapher.py
index bd93205..b973653 100755
--- a/plugins/grapher.py
+++ b/plugins/grapher.py
@@ -1,50 +1,35 @@
#!/usr/bin/python
'''
This script generates a data file that can be read by gnuplot or similar
-software. Columns, representing different data fields, may be generated via
-command line arguments. Current available columns include:
+software. The first column represent the date (cycle * epoch) of the Salis
+save file. The second column represents the number of organisms at that given
+dat.
-- current cycle: always present
-- number of organisms: activate with '-o' flag
+To run it, you may call it from within the ./bin/ directory (or wherever you
+keep your auto-saved files) inside the SALIS main directory, such as:
-To run it, simply call it from within the ./bin/ directory inside the SALIS
-main directory, such as:
+../plugins/grapher.py def.sim.*.auto
-../plugins/grapher.py -o def.sim.*.auto
-
-Calling this will create a single DATA file including data from all files
-matching the given pattern. This file may, in turn, be passed into gnuplot
-for generating graphs.
+Calling this will create a single DATA file (output.data) including data from
+all files matching the given pattern. This file may, in turn, be passed into
+gnuplot for generating graphs.
'''
import os
import sys
from ctypes import *
-current_arg = 1
-data_flags = []
-
-while sys.argv[current_arg][0] == '-':
- if sys.argv[current_arg] == '-o':
- data_flags.append('organism_count')
- print('organism count will be graphed')
- else:
- print('{} is not a valid flag'.format(sys.argv[current_arg]))
-
- current_arg += 1
-
-files = sys.argv[current_arg:]
oname = 'output.data'
salis = CDLL('libsalis.so')
-salis.s_getCycle.restype = c_uint
-salis.s_getEpoch.restype = c_uint
+salis.s_getCycle.restype = c_uint
+salis.s_getEpoch.restype = c_uint
salis.sp_getCount.restype = c_uint
with open(oname, 'w') as output:
- for f in files:
- salis.s_load(bytes(f, 'utf-8'))
+ for fileName in sys.argv[1:]:
+ salis.s_load(bytes(fileName, 'utf-8'))
cycle = salis.s_getCycle()
epoch = salis.s_getEpoch()
date = cycle + (epoch * (2 ** 32))
output.write('{} {}\n'.format(date, salis.sp_getCount()))
- print('info of date {} added to output.data'.format(date))
+ print('data of date {} added to \'output.data\''.format(date))
salis.s_quit()
diff --git a/plugins/imager.py b/plugins/imager.py
index fc7d77b..20d57d7 100755
--- a/plugins/imager.py
+++ b/plugins/imager.py
@@ -14,19 +14,20 @@ Calling this will create a PNG image for each file matching the given pattern.
By default, this script ignores any existing simulation files whose name
matches an existing image on the same directory. You may force it to overwrite
-existing images by passing the '-o' flag before the file list parameter.
+existing images by passing the '-o' or '--overwrite' flag. All other parameters
+are considered part of the file list.
'''
import os
import sys
from ctypes import *
from PIL import Image
-if sys.argv[1] == '-o':
+if '-o' in sys.argv or '--overwrite' in sys.argv:
overwrite = True
- files = sys.argv[2:]
+ sys.argv.remove('-o')
+ sys.argv.remove('--overwrite')
else:
overwrite = False
- files = sys.argv[1:]
salis = CDLL('libsalis.so')
salis.sm_getSize.restype = c_uint
@@ -37,22 +38,21 @@ def makeImage(iname):
if not overwrite:
if os.path.isfile('./' + oname):
print(oname + ' skipped')
- return
-
- salis.s_load(bytes(iname, 'utf-8'))
- lsize = int(salis.sm_getSize() ** 0.5)
- image = Image.new('L', (lsize, lsize), 'black')
- pixels = image.load()
-
- for y in range(lsize):
- for x in range(lsize):
- addr = (y * lsize) + x
- byte = salis.sm_getByteAt(addr)
- pixels[x, y] = byte
-
- salis.s_quit()
- image.save(oname)
- print(oname + ' generated')
-
-for f in files:
- makeImage(f)
+ else:
+ salis.s_load(bytes(iname, 'utf-8'))
+ lsize = int(salis.sm_getSize() ** 0.5)
+ image = Image.new('L', (lsize, lsize), 'black')
+ pixels = image.load()
+
+ for y in range(lsize):
+ for x in range(lsize):
+ addr = (y * lsize) + x
+ byte = salis.sm_getByteAt(addr)
+ pixels[x, y] = byte
+
+ salis.s_quit()
+ image.save(oname)
+ print(oname + ' generated')
+
+for fileName in sys.argv[1:]:
+ makeImage(fileName)
diff --git a/tsalis/include/printer.h b/tsalis/include/printer.h
index f5d8c3c..4430e88 100644
--- a/tsalis/include/printer.h
+++ b/tsalis/include/printer.h
@@ -20,6 +20,8 @@ void tsp_prevPage (void);
void tsp_nextPage (void);
void tsp_scrollUp (void);
void tsp_scrollDown (void);
+void tsp_fastScrollUp (void);
+void tsp_fastScrollDown (void);
void tsp_scrollLeft (void);
void tsp_scrollRight (void);
void tsp_scrollToTop (void);
diff --git a/tsalis/src/handler.c b/tsalis/src/handler.c
index f5be2c8..b1dae89 100644
--- a/tsalis/src/handler.c
+++ b/tsalis/src/handler.c
@@ -240,6 +240,14 @@ tsh_handleEvent(int event)
tsp_scrollRight();
break;
+ case 'W':
+ tsp_fastScrollDown();
+ break;
+
+ case 'S':
+ tsp_fastScrollUp();
+ break;
+
case 'Q':
tsp_scrollToTop();
break;
diff --git a/tsalis/src/printer.c b/tsalis/src/printer.c
index 88da4a8..c835f24 100644
--- a/tsalis/src/printer.c
+++ b/tsalis/src/printer.c
@@ -5,6 +5,8 @@
#include "printer.h"
#include "tsalis.h"
+#define PROC_PAGE_LINES_BEFORE_LIST 16
+
enum {
PAIR_NORMAL = 1,
PAIR_HEADER = 2,
@@ -111,18 +113,6 @@ tsp_init(void)
curs_set(0);
keypad(stdscr, TRUE);
start_color();
-
- if (can_change_color()) {
- init_color(COLOR_BLACK, 0, 0, 0);
- init_color(COLOR_RED, 700, 0, 0);
- init_color(COLOR_GREEN, 0, 700, 0);
- init_color(COLOR_YELLOW, 700, 700, 0);
- init_color(COLOR_BLUE, 0, 0, 700);
- init_color(COLOR_MAGENTA, 700, 0, 700);
- init_color(COLOR_CYAN, 0, 700, 700);
- init_color(COLOR_WHITE, 700, 700, 700);
- }
-
init_pair(PAIR_NORMAL, COLOR_WHITE, COLOR_BLACK);
init_pair(PAIR_HEADER, COLOR_CYAN, COLOR_BLACK);
init_pair(PAIR_SELECTED_PROC, COLOR_YELLOW, COLOR_BLACK);
@@ -213,6 +203,59 @@ tsp_scrollDown(void)
}
void
+tsp_fastScrollUp(void)
+{
+ switch (g_currentPage) {
+ case PAGE_PROCESS: {
+ sword toScroll = LINES - PROC_PAGE_LINES_BEFORE_LIST;
+
+ if (g_processVertScroll >= toScroll) {
+ g_processVertScroll -= toScroll;
+ } else {
+ g_processVertScroll = 0;
+ }
+ }
+
+ break;
+
+ case PAGE_WORLD:
+ if (g_worldPos >= g_worldArea) {
+ g_worldPos -= g_worldArea;
+ } else {
+ g_worldPos = 0;
+ }
+
+ break;
+ }
+
+ refresh();
+}
+
+void
+tsp_fastScrollDown(void)
+{
+ switch (g_currentPage) {
+ case PAGE_PROCESS: {
+ sword toScroll = LINES - PROC_PAGE_LINES_BEFORE_LIST;
+
+ if (g_processVertScroll < (sp_getCap() - toScroll)) {
+ g_processVertScroll += toScroll;
+ }
+ }
+
+ break;
+
+ case PAGE_WORLD:
+ if ((g_worldPos + g_worldArea) < sm_getSize()) {
+ g_worldPos += g_worldArea;
+ }
+
+ break;
+ }
+
+}
+
+void
tsp_scrollLeft(void)
{
switch (g_currentPage) {