//***********************************************************
//*
//* File:           RandomPlayer.java
//* Author:         Srikant Krishna
//* Contact:        srikant@cs.columbia.edu
//* Update:         10.16.2002
//*
//* Description:    Random player for Project 3.  Purely for
//*                 didactic purposes.
//*
//***********************************************************

package Rectangles;

import ui.*;
import java.util.*;
import java.io.*;
import java.awt.Color;

public final class RandomPlayer implements IFCPlayer {

    Rectangles _rect;
    static Random _random;
    static final String _CNAME = "Random Player";
    static final Color  _CCOLOR = new Color(0.6f, 0.7f, 0.4f);

    public Robot[] register(Rectangles __rectangles) throws Exception {
        Robot[] RET;
        int _MAX;
        int size;

        _rect = __rectangles;
        if (_random  == null) {
            _random = new Random();
        }

        _MAX = _rect.numRobots();
        size = _rect.size();
        RET = new Robot[_MAX];
        for (int i=0; i < _MAX; i++) {
            RET[i] = new Robot(_random.nextInt(size), _random.nextInt(size));
        }
        return RET;
    }

    public char[] move() throws Exception {
        int _MAX = _rect.numRobots();
        char[] RET = new char[_MAX];

        for (int i=0; i < _MAX; i++) {
            RET[i] = _CDIRECTIONS[_random.nextInt(_CDIRECTIONS.length - 1) + 1];
        }
        return RET;
    }

    public String name() throws Exception {
        return _CNAME;
    }

    public Color color() throws Exception {
        return _CCOLOR;
    }

    public boolean interactive() throws Exception {
        return false;
    }        
}
