source: liacs/ai/poker/data/pre-parse.pl@ 35

Last change on this file since 35 was 2, checked in by Rick van der Zwet, 15 years ago

Initial import of data of old repository ('data') worth keeping (e.g. tracking
means of URL access statistics)

  • Property svn:executable set to *
File size: 2.8 KB
RevLine 
[2]1#!/usr/bin/env perl -w
2
3while ($line = <STDIN>) {
4 #Input in way more every workable format
5 @numbers = split(',',$line);
6
7 #Get the number of every colour in on every line
8 @colour = (0, 0, 0, 0, 0);
9 foreach (0,2,4,6,8) {
10 $colour[$numbers[$_]]++;
11 }
12
13 #Find pairs, triples, four
14 @cards = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
15 foreach (1,3,5,7,9) {
16 $cards[$numbers[$_]]++;
17 }
18
19 ### BEGIN Specials ###
20 #triple = 1, four = 2
21 $special = 0;
22 #one pair = 1, two pair = 2
23 $pairs = 0;
24 ### END Specials ###
25
26 ### BEGIN decoded specials ###
27 $onepair = 0;
28 $twopair = 0;
29 $triple = 0;
30 $four = 0;
31 ### END decoded specials ###
32
33 foreach (1 .. 13) {
34 if ($cards[$_] == 2) {
35 $pairs++;
36 if ($pairs == 1) {
37 $onepair = 1;
38 } elsif ($pairs == 2) {
39 $twopair = 1;
40 }
41 } elsif ($cards[$_] > 2) {
42 $special = $cards[$_];
43 if ( $special == 3) {
44 $triple = 1;
45 } elsif ($special == 4) {
46 $four = 1;
47 }
48 }
49 }
50
51 #Decode into split option array
52 @output = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
53 $output[$numbers[10]]++;
54
55 $pairs /= 10;
56 $special /= 10;
57 foreach (0 .. 10) {
58 $numbers[$_] /= 10;
59 }
60 foreach (0 .. 4) {
61 $colour[$_] /= 10;
62 }
63
64 # Input 10 : all cards
65 # Output 1 : decoded version of result
66 #print "@numbers[0..10]\n";
67
68 # Input 10 : all cards
69 # Output 10 : all options, one node
70 print "@numbers[0..9] @output[0..9]\n";
71
72 # Input 14 : all cards + colours
73 # Output 10 : all options, one node
74 #print "@numbers[0..9] @colour[1..4] @output[0..9]\n";
75
76 # Input 16 : all cards + specials
77 # Output 10 : all options, every has it's one node
78 #print "@numbers[0..9] @colour[1..4] $pairs $special @output[0..9]\n";
79
80 # Input 14 : all cards + decoded specials
81 # Output 10 : all options, every has it's one node
82 #print "@numbers[0..9] $onepair $twopair $triple $four @output[0..9]\n";
83
84 # Input 18 : all cards + colour + decoded specials
85 # Output 10 : all options, every has it's one node
86 #print "@numbers[0..9] @colour[1..4] $onepair $twopair $triple $four @output[0..9]\n";
87
88 # Input 10: all cards
89 # output 2: full house, four of a kind
90 #print "@numbers[0..9] $output[6] $output[7]\n";
91
92 # Input 16 : all cards + specials
93 # output 1 : full house
94 #print "@numbers[0..9] @colour[1..4] $pairs $special $output[7]\n";
95
96 # Input 2 : Calculated set
97 # output 1 : full house
98 #print "$pair $special $output[6]\n";
99
100 # Input 8 : colour + decoded specials
101 # Output 10 : all options, every has it's one node
102 #print "@colour[1..4] $onepair $twopair $triple $four @output[0..9]\n";
103}
Note: See TracBrowser for help on using the repository browser.