Clojure bot
- Updated Sunday, July 12th 2015 @ 20:29:01
Hi,
I am trying to get started with an AI in Cljoure. For now, my bot is dumb and outputs "drop" after every input. Here is my code and my project.clj file:
(defproject ai-games-tetris "0.1.0-SNAPSHOT" :description "Simple clojurebot" :dependencies [[org.clojure/clojure "1.6.0"]] :main ai-games-tetris.core :profiles {:uberjar {:aot :all}})
(ns ai-games-tetris.core (:require [clojure.string :as str]) (:gen-class))
(defn parse-input [input] (str/split input #" "))
(defn get-input [] (let [buffer (read-line)] (parse-input buffer)))
(defn -main [& args] (while true (let [input (get-input) command (first input) arguments (rest input)] (println "drop") (flush))))
Right now, when I try to submit my bot, I get the following error:Running testcase /opt/aigames/etc/testsblockbattle/testblockbattle.txt... Testing Bot with setup input... ... finished testcase in 2.97999999672 seconds Test failed: no output
Any idea where I'm wrong?
- Created Sunday, July 12th 2015 @ 23:12:46
Similar problem was with my scala stareter bot because I forgot to call flush. But i see you call it (flush), so don't know..
- Created Monday, July 13th 2015 @ 10:08:23
What happens when you feed your bot input manually?
- Created Monday, July 13th 2015 @ 22:58:37
It works as expected. I start my program using "lein run". It waits for an input (some characters plus Enter) and prints drop on a new line after every input.
- Created Monday, July 13th 2015 @ 23:11:40
Have you seen the Clojure starterbot for the Warlight AI Challenge 2?
- Created Tuesday, July 14th 2015 @ 04:15:00
No I didn't see it, it helped a lot.
I finally found the problem 5 submits later. It seems like aigames completely ignores the leiningen project.clj file. I thought defining my main in that file was sufficient, and it is where I was wrong.
Instead, it is required that I launch my bot manually. It is what is done in the launcher.clj file of the Warlight 2 starter bot which contains only the line (bot/-main). When the reader evaluates this line, it calls the function "-main" from the namespace "bot".
I did like in the Warlight 2 starter bot and created a script that put all my sources in a single file with launcher.clj at the end.