Add Russian translation provided by Валерий Крувялис <valkru@mail.ru>
[xiph-mirror.git] / planarity / graph_generate_data.c
blob608becb187f834f5635f023ee054487d58c03a9b
1 /*
3 * gPlanarity:
4 * The geeky little puzzle game with a big noodly crunch!
5 *
6 * gPlanarity copyright (C) 2005 Monty <monty@xiph.org>
7 * Original Flash game by John Tantalo <john.tantalo@case.edu>
8 * Original game concept by Mary Radcliffe
10 * gPlanarity is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2, or (at your option)
13 * any later version.
15 * gPlanarity is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with Postfish; see the file COPYING. If not, write to the
22 * Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
27 #include <stdlib.h>
28 #include <string.h>
30 #include "graph.h"
31 #include "graph_generate.h"
33 typedef struct d_vertex{
34 int x;
35 int y;
36 } d_vertex;
38 typedef struct d_edge{
39 int a;
40 int b;
41 } d_edge;
43 typedef struct d_level{
44 int obj;
45 int less;
46 d_vertex *v;
47 d_edge *e;
48 } d_level;
50 static d_vertex v_level1[] = {
51 {400,30}, {143,216}, {241,518}, {559,518}, {657,216},
52 {282,138}, {210,362}, {400,500}, {590,362}, {518,138},
53 {-1,-1},
56 static d_edge e_level1[] = {
57 {0,5}, {5,1}, {0,2}, {0,3}, {0,9}, {9,4}, {1,6}, {6,2},
58 {1,3}, {1,4}, {2,7}, {7,3}, {2,4}, {3,8}, {8,4},{-1,-1},
61 static d_level leveldata[] = {
62 {1,0,v_level1,e_level1}
68 void generate_data(graph *g, int order){
69 int i;
70 d_level *l = leveldata+order;
71 vertex *vlist;
72 vertex **flat;
74 // scan for number of verticies
75 i=0;
76 while(l->v[i].x != -1)i++;
77 vlist=new_board(g, i);
78 flat = alloca(i*sizeof(*flat));
80 // build graph from data
81 // add verticies
83 vertex *v=vlist;
84 i=0;
85 while(v){
86 v->x = l->v[i].x;
87 v->y = l->v[i].y;
88 flat[i++]=v;
89 v=v->next;
93 // add edges
95 int i=0;
96 while(l->e[i].a != -1){
97 add_edge(g,flat[l->e[i].a],flat[l->e[i].b]);
98 i++;
102 g->objective = l->obj;
103 g->objective_lessthan = l->less;