comparison src/requests.tp @ 31:8a2925ab0d4a

working guess request and response.
author William Morgan <bill@mrgn.org>
date Sat, 10 Aug 2013 21:23:33 -0700
parents a4bffcd381cd
children 9d5c3b078c78
comparison
equal deleted inserted replaced
30:a4bffcd381cd 31:8a2925ab0d4a
60 evalResponse: resp 60 evalResponse: resp
61 } 61 }
62 } 62 }
63 } 63 }
64 64
65 guessRequest <- :id :prog { 65 guess <- :id :prog {
66 #{ 66 #{
67 string <- { 67 string <- {
68 idStr <- "\"id\":\"" . id . "\"" 68 idStr <- "\"id\":\"" . id . "\""
69 progStr <- "\"program\":\"" . prog . "\"" 69 progStr <- "\"program\":\"" . prog . "\""
70 "{" . idStr . "," . progStr . "}" 70 "{" . idStr . "," . progStr . "}"
71 }
72 sendWithKey <- :key {
73 print: "Sending: " . string . "\n"
74 cli <- http client: "icfpc2013.cloudapp.net"
75 resp <- cli post: string toPath: "/guess?auth=" . key withType: "application/json"
76 guessResponse: resp
71 } 77 }
72 } 78 }
73 } 79 }
74 80
75 evalResponse <- :httpResp { 81 evalResponse <- :httpResp {
171 #{print <- print: "HTTP response gave error! code was: " . _code . "\n"} 177 #{print <- print: "HTTP response gave error! code was: " . _code . "\n"}
172 } 178 }
173 } 179 }
174 180
175 main <- :args { 181 main <- :args {
176 print: ((evalId: "someId" #[1u64 2u64 3u64]) string) . "\n" 182 //print: ((evalId: "someId" #[1u64 2u64 3u64]) string) . "\n"
177 print: ((guessRequest: "someId" "someProg") string) . "\n" 183 //print: ((guess: "someId" "someProg") string) . "\n"
178 184
179 if: (args length) > 1 { 185 if: (args length) > 1 {
180 key <- args get: 1 186 key <- args get: 1
187 testId <- "wdThP1AgVrS2rp7q6qt9mLqp" // my first training problem
188 someId <- "QwhG7ZpaVsfXiLRvbJfIfxl8" // TRAINING PROGRAM IDs!!! not real ones.
189
190 someProgram <- "(lambda (input) (shl1 input))"
191
181 //print: ((evalProgram: "(lambda (input) (shl1 input))" #[1u64 0xEFFFFFFFFFFFFFu64]) sendWithKey: key) 192 //print: ((evalProgram: "(lambda (input) (shl1 input))" #[1u64 0xEFFFFFFFFFFFFFu64]) sendWithKey: key)
182 print: ((evalId: "QwhG7ZpaVsfXiLRvbJfIfxl8" #[1u64 0xEFFFFFFFFFFFFFu64]) sendWithKey: key) 193 //print: ((evalId: testId #[1u64 0xEFFFFFFFFFFFFFu64]) sendWithKey: key)
194 print: ((guess: testId someProgram) sendWithKey: key)
195
183 } 196 }
184 } 197 }
185 } 198 }