Back to project page MiReversi.
The source code is released under:
MIT License
If you think the Android project MiReversi listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
/* * Copyright (c) 2011 Makoto Ishida//from w ww.j ava2 s. c om * Please see the file MIT-LICENSE.txt for copying permission. */ package com.example.mireversi.model; import java.util.ArrayList; import java.util.Random; import android.graphics.Point; import com.example.mireversi.model.Cell.E_STATUS; public class ComputerPlayerLevel0 extends ComputerPlayer { private static int WAIT_MSEC = 10; private Random mRnd; public ComputerPlayerLevel0(E_STATUS turn, String name, Board board){ super(turn, name, board); mRnd = new Random(); } @Override protected Point think() { Point pos = null; try { Thread.sleep(WAIT_MSEC); } catch (InterruptedException e) { setStopped(true); } if (isStopped()) return pos; //???????????????????????????? //???????????????????????????? ArrayList<Cell> available_cells = mBoard.getAvailableCells(); if (available_cells.size() == 0){ return pos; } if (isStopped()) return pos; //???????????????????????????? //????????????????????????????????? int n = mRnd.nextInt(available_cells.size()); Cell chosenCell = available_cells.get(n); pos = chosenCell.getPoint(); return pos; } }