contrib: delete the memory game
[nit.git] / contrib / friendz / src / solver_cmd.nit
1 # Monsterz - Chains of Friends
2 #
3 # 2010-2014 (c) Jean Privat <jean@pryen.org>
4 #
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the Do What The Fuck You Want To
7 # Public License, Version 2, as published by Sam Hocevar. See
8 # http://sam.zoy.org/projects/COPYING.WTFPL for more details.
9
10 # Solver of levels on the command-line
11 module solver_cmd
12
13 import solver
14 import level
15
16
17 if args.is_empty then
18 print "Usage: solver_cmd levelnumber"
19 exit 0
20 end
21 var l = args.first.to_i
22 var game = new Game
23 var g = game.grid
24
25 g.load(game.levels[l].str)
26 g.size_problem
27
28 var p = new FriendzProblem(g)
29 var s = p.solve
30 while s.is_running do
31 var r = s.run_steps(500000)
32 if r != null then
33 print "WON"
34 break
35 else if s.is_running then
36 print s
37 print g
38 end
39 end
40 print s
41 printn g