|
Last change
on this file since 1092 was
745,
checked in by Maciej Komosinski, 8 years ago
|
|
Renamed ParamInterface::save() -> saveMultiLine()
|
|
File size:
1.1 KB
|
| Line | |
|---|
| 1 | // This file is a part of Framsticks SDK. http://www.framsticks.com/
|
|---|
| 2 | // Copyright (C) 1999-2015 Maciej Komosinski and Szymon Ulatowski.
|
|---|
| 3 | // See LICENSE.txt for details.
|
|---|
| 4 |
|
|---|
| 5 | #include "genotypeloader.h"
|
|---|
| 6 | #include <common/virtfile/stdiofile.h>
|
|---|
| 7 |
|
|---|
| 8 | /**
|
|---|
| 9 | @file
|
|---|
| 10 | Sample code: Saving genotypes
|
|---|
| 11 |
|
|---|
| 12 | \include saver_test_geno.cpp
|
|---|
| 13 | */
|
|---|
| 14 |
|
|---|
| 15 | int main(int argc, char*argv[])
|
|---|
| 16 | {
|
|---|
| 17 | if (argc < 3)
|
|---|
| 18 | {
|
|---|
| 19 | fprintf(stderr, "Arguments: filename number_of_genotypes\n"
|
|---|
| 20 | "Example: saver_test_geno file.gen 3\n"
|
|---|
| 21 | );
|
|---|
| 22 | return 1;
|
|---|
| 23 | }
|
|---|
| 24 |
|
|---|
| 25 | StdioFileSystem_autoselect stdiofilesys;
|
|---|
| 26 | VirtFILE *f = Vfopen(argv[1], "w");
|
|---|
| 27 | if (f)
|
|---|
| 28 | {
|
|---|
| 29 | int N = atoi(argv[2]);
|
|---|
| 30 | GenotypeMini g;
|
|---|
| 31 | Param p(genotypemini_paramtab, &g);
|
|---|
| 32 | g.clear();
|
|---|
| 33 | printf("Saving %d genotypes to %s\n", N, argv[1]);
|
|---|
| 34 | for (int i = 1; i <= N; i++)
|
|---|
| 35 | {
|
|---|
| 36 | g.name = SString::sprintf("Genotype#%d", i);
|
|---|
| 37 | g.genotype = ""; for (int x = 0; x < i; x++) g.genotype += "X";
|
|---|
| 38 | g.velocity = 0.1*i;
|
|---|
| 39 | g.energy0 = 1;
|
|---|
| 40 | g.info = "Saved by saver_test_geno.cpp";
|
|---|
| 41 | g.is_valid = 1;
|
|---|
| 42 | p.saveMultiLine(f, "org");
|
|---|
| 43 | }
|
|---|
| 44 | delete f;
|
|---|
| 45 | return 0;
|
|---|
| 46 | }
|
|---|
| 47 | else
|
|---|
| 48 | {
|
|---|
| 49 | printf("Could not write to %s\n", argv[1]);
|
|---|
| 50 | return 1;
|
|---|
| 51 | }
|
|---|
| 52 | }
|
|---|
Note: See
TracBrowser
for help on using the repository browser.