Source code: com/adorphuye/othello/player/Player.java
1 package com.adorphuye.othello.player;
2
3 import com.adorphuye.othello.gui.board.*;
4
5 public abstract class Player implements BoardListener
6 {
7 public static final int MAX_DEPTH = 6;
8 public static final int MIN_DEPTH = 1;
9 public static final int DEFAULT_DEPTH = 1;
10 private BoardDataModel model = null;
11 private static int playernum = 1;
12 private int mynum = -1;
13
14 protected Player()
15 {
16 }
17
18 /**
19 * @param mod
20 * @param num */
21 public Player(BoardDataModel mod, int num)
22 {
23 setIndex(num);
24 setModel(mod);
25 }
26
27 /**
28 * @param num */
29 public void setIndex(int num)
30 {
31 mynum = num;
32 }
33
34 public abstract void play();
35 public abstract void reset();
36
37 /**
38 * @return */
39 public int getIndex()
40 {
41 return mynum;
42 }
43
44 /**
45 * @return */
46 public String toString()
47 {
48 return "Player"+mynum;
49 }
50
51
52 /**
53 * @return */
54 public int getSide()
55 {
56 return getIndex();
57 }
58
59 /**
60 * @param mod */
61 public void setModel(BoardDataModel mod)
62 {
63 if(model!=null)
64 {
65 model.removeBoardListener(this);
66 }
67 model = mod;
68 model.addBoardListener(this);
69 }
70
71 /**
72 * @return */
73 public BoardDataModel getModel()
74 {
75 return model;
76 }
77
78 public void boardChanged(BoardEvent e)
79 {
80 }
81
82 }