1 package ru.bosony.solvers;
3 import java.util.HashMap;
6 import ru.bosony.model.mine.Mine;
9 * @author indvdum (gotoindvdum[at]gmail[dot]com) <br>
13 public abstract class AbstractSolver {
15 protected Mine mine = null;
16 protected SolverListener listener = null;
17 protected Map<String, Integer> routesWithScore = new HashMap<String, Integer>();
18 protected long attemptsCount = 0;
20 public AbstractSolver(Mine mine, SolverListener listener) {
22 this.listener = listener;
25 protected void addNewRoute(String route, int score) {
26 if (!routesWithScore.containsKey(route) && score > getMaxFoundScore()) {
27 routesWithScore.put(route, score);
28 listener.foundNextRoute(route);
32 protected int getMaxFoundScore() {
34 for (int foundScore : routesWithScore.values()) {
35 if (foundScore > maxScore)
36 maxScore = foundScore;
41 public abstract void solve();