WPBDC 2013.1.6 → 2013.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/ext/WPBDC/judge.c +64 -26
- data/ext/WPBDC/judge.h +4 -1
- data/ext/WPBDC/rubydefs.h +3 -1
- data/ext/WPBDC/scenario.c +10 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MmM1MDlkNTI1YWUyOTM5OTNjYTA3YWQ5NTIzNDBkMGM0MmZiMmQyMA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MGJhOTAxMTNhZDkwYzk5YTAyNmViZTc1M2IxNTY5Y2VlNTRmNjQ2MQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OGEwMGMwOGIwMjQ0MGUwM2UzMjBjM2EzNGNkNzQ2ZDRmNzhhZjhmNTI4NjM3
|
10
|
+
YzNkN2I5MWM5MTk1MjE2ZTNhZDFlMTdiYWQ4OTBjMzQ1Mzc3YTdlMTUyZDQ0
|
11
|
+
ZThhMDFkNWQ5YzQyZDZkYTRiZGQ1M2RmMjg5NzYyMWVjMmE5NjA=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MDVmNTZhZjE5YWYzOTIxYWI3NWY5N2M3MjUzZWJmYzYzMTQzZjRhNzgyYmQ3
|
14
|
+
MWYwMGY3YWM3MDc3NDZhYzM5ZmM4YWRjMzI3YzllOGM5YjIzNTg3MDliNjcw
|
15
|
+
MjY5ZGM0OTlkYWYwNjRiMWE1YzVjMTUxMDI5MWMwYjQ1NDIwOGI=
|
data/ext/WPBDC/judge.c
CHANGED
@@ -206,16 +206,52 @@ char *analysis_table(STRING *bridge_as_string)
|
|
206
206
|
//#define WRITE_EXAMPLES
|
207
207
|
|
208
208
|
#ifdef WRITE_EXAMPLES
|
209
|
-
#define EG_DIR "
|
210
|
-
#define NEW_EG_DIR "
|
209
|
+
#define EG_DIR "../../test/eg/2012"
|
210
|
+
#define NEW_EG_DIR "../../test/eg/2013"
|
211
211
|
#else
|
212
|
-
#define EG_DIR "
|
212
|
+
#define EG_DIR "../../test/eg/2012"
|
213
213
|
#endif
|
214
214
|
|
215
|
-
#
|
215
|
+
#ifdef WINDOWS
|
216
216
|
#include <crtdbg.h>
|
217
|
+
#endif
|
218
|
+
|
217
219
|
#include <sys/types.h>
|
218
220
|
#include <sys/stat.h>
|
221
|
+
#include <dirent.h>
|
222
|
+
|
223
|
+
void strcpyn(char *dst, char *src, int n)
|
224
|
+
{
|
225
|
+
while (n-- > 0 && *src)
|
226
|
+
*dst++ = *src++;
|
227
|
+
*dst = '\0';
|
228
|
+
}
|
229
|
+
|
230
|
+
void split_path(char *path, char *drv, char *dir, char *fname, char *ext)
|
231
|
+
{
|
232
|
+
int len = strlen(path);
|
233
|
+
char *colon, *slash, *dot;
|
234
|
+
|
235
|
+
colon = strchr(path, ':');
|
236
|
+
if (colon) {
|
237
|
+
if (drv) strcpyn(drv, path, colon - path + 1);
|
238
|
+
path = colon + 1;
|
239
|
+
}
|
240
|
+
slash = strrchr(path, '/');
|
241
|
+
if (slash) {
|
242
|
+
if (dir) strcpyn(dir, path, slash - path + 1);
|
243
|
+
path = slash + 1;
|
244
|
+
}
|
245
|
+
dot = strrchr(path, '.');
|
246
|
+
if (dot) {
|
247
|
+
if (ext) strcpy(ext, dot);
|
248
|
+
if (fname) strcpyn(fname, path, dot - path);
|
249
|
+
}
|
250
|
+
else {
|
251
|
+
if (ext) strcpy(ext, "");
|
252
|
+
if (fname) strcpy(fname, path);
|
253
|
+
}
|
254
|
+
}
|
219
255
|
|
220
256
|
void split_fn(char *fn, char *path, char *name, char *ext)
|
221
257
|
{
|
@@ -250,6 +286,7 @@ int main(int argc, char* argv[])
|
|
250
286
|
{
|
251
287
|
extern unsigned contest_year; // ugly hack go read other years' bridge files
|
252
288
|
|
289
|
+
DIR *d;
|
253
290
|
FILE *f;
|
254
291
|
char fname[256];
|
255
292
|
char raw[4*1024];
|
@@ -259,6 +296,7 @@ int main(int argc, char* argv[])
|
|
259
296
|
char buf[256], path[256], name[256], ext[256];
|
260
297
|
char *text;
|
261
298
|
struct analysis_result_t result[1];
|
299
|
+
struct dirent *dir_ent;
|
262
300
|
|
263
301
|
TBridge bridge[1];
|
264
302
|
TBridge copy[1];
|
@@ -268,7 +306,6 @@ int main(int argc, char* argv[])
|
|
268
306
|
TAnalysis anal[1];
|
269
307
|
int i, n, test_case;
|
270
308
|
long h;
|
271
|
-
struct _finddata_t file_data[1];
|
272
309
|
COMPRESSED_IMAGE compressed_image[1];
|
273
310
|
|
274
311
|
#ifdef WRITE_EXAMPLES
|
@@ -288,6 +325,12 @@ int main(int argc, char* argv[])
|
|
288
325
|
}
|
289
326
|
#endif
|
290
327
|
|
328
|
+
d = opendir (EG_DIR "/");
|
329
|
+
if (!d) {
|
330
|
+
perror ("Couldn't open test input directory " EG_DIR);
|
331
|
+
return 17;
|
332
|
+
}
|
333
|
+
|
291
334
|
init_bridge(bridge);
|
292
335
|
init_bridge(copy);
|
293
336
|
init_geometry(geometry);
|
@@ -302,26 +345,21 @@ int main(int argc, char* argv[])
|
|
302
345
|
return 1;
|
303
346
|
|
304
347
|
for (test_case = 1;;test_case++) {
|
305
|
-
|
306
|
-
if (
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
return 17;
|
311
|
-
}
|
312
|
-
}
|
313
|
-
else {
|
314
|
-
if (_findnext(h, file_data) != 0) {
|
315
|
-
_findclose(h);
|
316
|
-
test_case--;
|
317
|
-
break;
|
318
|
-
}
|
348
|
+
dir_ent = readdir(d);
|
349
|
+
if (!dir_ent) {
|
350
|
+
closedir(d);
|
351
|
+
test_case--;
|
352
|
+
break;
|
319
353
|
}
|
320
|
-
if (
|
354
|
+
if (strstr(dir_ent->d_name, ".bdc") == NULL)
|
355
|
+
continue;
|
356
|
+
|
357
|
+
// SINGLE TEST CASE!
|
358
|
+
if (strcmp(dir_ent->d_name, "semis-01.bdc") != 0)
|
321
359
|
continue;
|
322
360
|
|
323
|
-
printf("Test case %d (%s):\n", test_case,
|
324
|
-
sprintf(fname, EG_DIR "/%s",
|
361
|
+
printf("Test case %d (%s):\n", test_case, dir_ent->d_name);
|
362
|
+
sprintf(fname, EG_DIR "/%s", dir_ent->d_name);
|
325
363
|
f = fopen(fname, "rb");
|
326
364
|
if (!f) {
|
327
365
|
printf("can't open bridge file\n");
|
@@ -361,13 +399,13 @@ int main(int argc, char* argv[])
|
|
361
399
|
|
362
400
|
#ifdef WRITE_EXAMPLES
|
363
401
|
|
364
|
-
if (!strstr(
|
402
|
+
if (!strstr(dir_ent->d_name, "failed")) {
|
365
403
|
|
366
404
|
struct _stat stat_buf[1];
|
367
405
|
|
368
406
|
n_examples_read++;
|
369
407
|
|
370
|
-
split_fn(
|
408
|
+
split_fn(dir_ent->d_name, path, name, ext);
|
371
409
|
|
372
410
|
n = fix_failure(copy, bridge, params);
|
373
411
|
|
@@ -509,7 +547,7 @@ int main(int argc, char* argv[])
|
|
509
547
|
|
510
548
|
if (text) {
|
511
549
|
printf("writing analysis...");
|
512
|
-
|
550
|
+
split_path(dir_ent->d_name, 0, path, name, ext);
|
513
551
|
sprintf(buf, "Debug/html/%s.htm", name);
|
514
552
|
f = fopen(buf, "w");
|
515
553
|
if (!f) {
|
@@ -540,7 +578,7 @@ int main(int argc, char* argv[])
|
|
540
578
|
|
541
579
|
// Do a sketch
|
542
580
|
sketch(bridge_str, 300, 300, compressed_image, result);
|
543
|
-
|
581
|
+
split_path(dir_ent->d_name, 0, path, name, ext);
|
544
582
|
sprintf(buf, "Debug/sketch/%s.png", name);
|
545
583
|
f = fopen(buf, "wb");
|
546
584
|
if (!f) {
|
data/ext/WPBDC/judge.h
CHANGED
@@ -17,7 +17,10 @@
|
|
17
17
|
|
18
18
|
// The id for the semifinal scenario including a null value
|
19
19
|
#define NULL_SEMIFINAL_SCENARIO_ID "0000000000"
|
20
|
-
|
20
|
+
|
21
|
+
// When you set this, you _must_ change the scenario table so its record is in sorted order!
|
22
|
+
#define SEMIFINAL_SCENARIO_ID "3100003100"
|
23
|
+
//#define SEMIFINAL_SCENARIO_ID NULL_SEMIFINAL_SCENARIO_ID
|
21
24
|
|
22
25
|
// Status returns from analyze().
|
23
26
|
#define BRIDGE_OK 0
|
data/ext/WPBDC/rubydefs.h
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#ifndef _RUBYDEFS_H
|
2
2
|
#define _RUBYDEFS_H
|
3
3
|
|
4
|
-
#if !defined(
|
4
|
+
#if !defined(NATIVE_TEST)
|
5
5
|
|
6
6
|
#include <ruby.h>
|
7
7
|
|
@@ -41,6 +41,8 @@
|
|
41
41
|
|
42
42
|
#else
|
43
43
|
|
44
|
+
#include <stdio.h>
|
45
|
+
|
44
46
|
#define New(x,v,n,t) \
|
45
47
|
do { \
|
46
48
|
if ( !(v = (t*)malloc((n)*sizeof(t))) ) { \
|
data/ext/WPBDC/scenario.c
CHANGED
@@ -10,7 +10,6 @@
|
|
10
10
|
// Lookup table is sorted on 10-char ID field for binary search.
|
11
11
|
// The search routine will bubble the semifinal row to the right location.
|
12
12
|
static TScenarioDescriptor scenario_descriptor_tbl[] = {
|
13
|
-
{ 999, SEMIFINAL_SCENARIO_ID, "99Z", 100000.00 },
|
14
13
|
{ 0, "1050824100", "27A", 99874.40 },
|
15
14
|
{ 1, "1051220100", "32A", 105140.00 },
|
16
15
|
{ 2, "1051616100", "36A", 111994.40 },
|
@@ -272,6 +271,7 @@ static TScenarioDescriptor scenario_descriptor_tbl[] = {
|
|
272
271
|
{ 258, "3091616300", "17C", 108700.00 },
|
273
272
|
{ 259, "3091616350", "84C", 112200.00 },
|
274
273
|
{ 260, "3091616351", "88C", 120200.00 },
|
274
|
+
{ 999, SEMIFINAL_SCENARIO_ID, "99Z", 100000.00 },
|
275
275
|
{ 261, "3100804100", "22C", 88840.40 },
|
276
276
|
{ 262, "3101204060", "54C", 94500.00 },
|
277
277
|
{ 263, "3101204360", "82C", 106500.00 },
|
@@ -434,6 +434,8 @@ int lookup_scenario_descriptor(TScenarioDescriptor *desc, char *id)
|
|
434
434
|
int hi = STATIC_ARRAY_SIZE(scenario_descriptor_tbl) - 1;
|
435
435
|
int i, cmp, mid;
|
436
436
|
|
437
|
+
/* NOT THREAD SAFE. DO BY HAND!
|
438
|
+
|
437
439
|
// Bubble the semifinal scenario to the right position one time.
|
438
440
|
if (!initialized_p) {
|
439
441
|
initialized_p = 1;
|
@@ -446,11 +448,16 @@ int lookup_scenario_descriptor(TScenarioDescriptor *desc, char *id)
|
|
446
448
|
}
|
447
449
|
scenario_descriptor_tbl[i] = semifinal_descriptor;
|
448
450
|
}
|
451
|
+
*/
|
452
|
+
|
453
|
+
// TODO Remove
|
454
|
+
fprintf(stderr, "looking for %.10s\n", id);
|
449
455
|
|
450
456
|
// Don't bother searching for the null semifinal scenario.
|
451
457
|
if (strncmp(id, NULL_SEMIFINAL_SCENARIO_ID, SCENARIO_ID_SIZE) != 0) {
|
452
458
|
|
453
459
|
while (lo <= hi) {
|
460
|
+
fprintf(stderr, "SEARCH [%d, %d]\n", lo, hi);
|
454
461
|
mid = (unsigned)(lo + hi) >> 1;
|
455
462
|
cmp = strncmp(id, scenario_descriptor_tbl[mid].id, SCENARIO_ID_SIZE);
|
456
463
|
if (cmp < 0)
|
@@ -658,6 +665,8 @@ int test_scenario_table(void)
|
|
658
665
|
printf("scenario lookup check (find good indices): ");
|
659
666
|
for (i = 0; i < STATIC_ARRAY_SIZE(scenario_descriptor_tbl); i++) {
|
660
667
|
printf("%d ", i);
|
668
|
+
if (strncmp(scenario_descriptor_tbl[i].id, NULL_SEMIFINAL_SCENARIO_ID, SCENARIO_ID_SIZE) == 0)
|
669
|
+
continue;
|
661
670
|
if (lookup_scenario_descriptor(desc, scenario_descriptor_tbl[i].id) < 0) {
|
662
671
|
printf("\nfailed to find scenario id %s (position %d)\n",
|
663
672
|
scenario_descriptor_tbl[i].id, i);
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: WPBDC
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2013.1.
|
4
|
+
version: 2013.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gene Ressler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-07-12 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Container for C code extension that implements the West Point Bridge
|
14
14
|
Contest Judge.
|