Last change
on this file since 1302 was
745,
checked in by Maciej Komosinski, 7 years ago
|
Renamed ParamInterface::save() -> saveMultiLine()
|
File size:
1.1 KB
|
Rev | Line | |
---|
[517] | 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
|
---|
[520] | 13 | */
|
---|
[517] | 14 |
|
---|
[520] | 15 | int main(int argc, char*argv[])
|
---|
[517] | 16 | {
|
---|
[520] | 17 | if (argc < 3)
|
---|
[517] | 18 | {
|
---|
[520] | 19 | fprintf(stderr, "Arguments: filename number_of_genotypes\n"
|
---|
| 20 | "Example: saver_test_geno file.gen 3\n"
|
---|
| 21 | );
|
---|
| 22 | return 1;
|
---|
[517] | 23 | }
|
---|
| 24 |
|
---|
[520] | 25 | StdioFileSystem_autoselect stdiofilesys;
|
---|
| 26 | VirtFILE *f = Vfopen(argv[1], "w");
|
---|
| 27 | if (f)
|
---|
[517] | 28 | {
|
---|
[520] | 29 | int N = atoi(argv[2]);
|
---|
[732] | 30 | GenotypeMini g;
|
---|
| 31 | Param p(genotypemini_paramtab, &g);
|
---|
[520] | 32 | g.clear();
|
---|
| 33 | printf("Saving %d genotypes to %s\n", N, argv[1]);
|
---|
| 34 | for (int i = 1; i <= N; i++)
|
---|
[517] | 35 | {
|
---|
[520] | 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;
|
---|
[745] | 42 | p.saveMultiLine(f, "org");
|
---|
[517] | 43 | }
|
---|
[520] | 44 | delete f;
|
---|
| 45 | return 0;
|
---|
[517] | 46 | }
|
---|
[520] | 47 | else
|
---|
[517] | 48 | {
|
---|
[520] | 49 | printf("Could not write to %s\n", argv[1]);
|
---|
| 50 | return 1;
|
---|
[517] | 51 | }
|
---|
| 52 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.