Section 1
//BitmapAsset (mx.core.BitmapAsset)
package mx.core {
import flash.display.*;
public class BitmapAsset extends FlexBitmap implements IFlexAsset, IFlexDisplayObject {
mx_internal static const VERSION:String = "2.0.1.0";
public function BitmapAsset(_arg1:BitmapData=null, _arg2:String="auto", _arg3:Boolean=false){
super(_arg1, _arg2, _arg3);
}
public function get measuredWidth():Number{
if (bitmapData){
return (bitmapData.width);
};
return (0);
}
public function get measuredHeight():Number{
if (bitmapData){
return (bitmapData.height);
};
return (0);
}
public function setActualSize(_arg1:Number, _arg2:Number):void{
width = _arg1;
height = _arg2;
}
public function move(_arg1:Number, _arg2:Number):void{
this.x = _arg1;
this.y = _arg2;
}
}
}//package mx.core
Section 2
//FlexBitmap (mx.core.FlexBitmap)
package mx.core {
import flash.display.*;
import mx.utils.*;
public class FlexBitmap extends Bitmap {
mx_internal static const VERSION:String = "2.0.1.0";
public function FlexBitmap(_arg1:BitmapData=null, _arg2:String="auto", _arg3:Boolean=false){
var bitmapData = _arg1;
var pixelSnapping = _arg2;
var smoothing = _arg3;
super(bitmapData, pixelSnapping, smoothing);
try {
name = NameUtil.createUniqueName(this);
} catch(e:Error) {
};
}
override public function toString():String{
return (NameUtil.displayObjectToString(this));
}
}
}//package mx.core
Section 3
//IFlexAsset (mx.core.IFlexAsset)
package mx.core {
public interface IFlexAsset {
}
}//package mx.core
Section 4
//IFlexDisplayObject (mx.core.IFlexDisplayObject)
package mx.core {
import flash.events.*;
import flash.display.*;
public interface IFlexDisplayObject extends IBitmapDrawable, IEventDispatcher {
function get name():String;
function set width(_arg1:Number):void;
function get measuredHeight():Number;
function set height(_arg1:Number):void;
function get scaleY():Number;
function move(_arg1:Number, _arg2:Number):void;
function get scaleX():Number;
function set mask(_arg1:DisplayObject):void;
function set scaleX(_arg1:Number):void;
function set name(_arg1:String):void;
function set scaleY(_arg1:Number):void;
function get visible():Boolean;
function get measuredWidth():Number;
function set visible(_arg1:Boolean):void;
function get alpha():Number;
function get height():Number;
function get width():Number;
function get parent():DisplayObjectContainer;
function get mask():DisplayObject;
function set x(_arg1:Number):void;
function setActualSize(_arg1:Number, _arg2:Number):void;
function set y(_arg1:Number):void;
function get x():Number;
function get y():Number;
function set alpha(_arg1:Number):void;
}
}//package mx.core
Section 5
//IRepeaterClient (mx.core.IRepeaterClient)
package mx.core {
public interface IRepeaterClient {
function set instanceIndices(_arg1:Array):void;
function get isDocument():Boolean;
function get repeaters():Array;
function get instanceIndices():Array;
function set repeaters(_arg1:Array):void;
function initializeRepeaterArrays(_arg1:IRepeaterClient):void;
function set repeaterIndices(_arg1:Array):void;
function get repeaterIndices():Array;
}
}//package mx.core
Section 6
//mx_internal (mx.core.mx_internal)
package mx.core {
public namespace mx_internal = "http://www.adobe.com/2006/flex/mx/internal";
}//package mx.core
Section 7
//NameUtil (mx.utils.NameUtil)
package mx.utils {
import flash.display.*;
import mx.core.*;
import flash.utils.*;
public class NameUtil {
mx_internal static const VERSION:String = "2.0.1.0";
private static var counter:int = 0;
public static function displayObjectToString(_arg1:DisplayObject):String{
var _local2:String;
var _local3:DisplayObject;
var _local4:String;
var _local5:Array;
_local3 = _arg1;
while (_local3 != null) {
if (((((_local3.parent) && (_local3.stage))) && ((_local3.parent == _local3.stage)))){
break;
};
_local4 = _local3.name;
if ((_local3 is IRepeaterClient)){
_local5 = IRepeaterClient(_local3).instanceIndices;
if (_local5){
_local4 = (_local4 + (("[" + _local5.join("][")) + "]"));
};
};
_local2 = ((_local2 == null)) ? _local4 : ((_local4 + ".") + _local2);
_local3 = _local3.parent;
};
return (_local2);
}
public static function createUniqueName(_arg1:Object):String{
var _local2:String;
var _local3:int;
var _local4:int;
if (!_arg1){
return (null);
};
_local2 = getQualifiedClassName(_arg1);
_local3 = _local2.indexOf("::");
if (_local3 != -1){
_local2 = _local2.substr((_local3 + 2));
};
_local4 = _local2.charCodeAt((_local2.length - 1));
if ((((_local4 >= 48)) && ((_local4 <= 57)))){
_local2 = (_local2 + "_");
};
return ((_local2 + counter++));
}
}
}//package mx.utils
Section 8
//BSDRandom (BSDRandom)
package {
public class BSDRandom {
public var seed:int;
public function BSDRandom(_arg1:int=0):void{
if (_arg1 > 0){
seed = _arg1;
} else {
seed = new Date().time;
};
}
public function sign():int{
if (next(2) == 0){
return (1);
};
return (-1);
}
public function percent(_arg1:int):Boolean{
return ((next(100) < _arg1));
}
public function number(_arg1:int=1):Number{
return ((next(65536, _arg1) / 65536));
}
public function next(_arg1:int, _arg2:int=1):int{
var _local3:int;
var _local4:int;
var _local5:int;
var _local6:int;
if (_arg1 == 0){
return (0);
};
if (_arg2 < 1){
_arg2 = 1;
};
_local5 = 0;
_local6 = 0;
while (_local6 < _arg2) {
_local3 = Math.floor((seed / 127773));
_local4 = (seed % 127773);
seed = ((16807 * _local4) - (2836 * _local3));
if (seed <= 0){
seed = (seed + 2147483647);
};
seed = (seed & 2147483647);
if (seed == 0){
seed = 1;
};
_local5 = (_local5 + (seed % _arg1));
_local6++;
};
return ((_local5 / _arg2));
}
public function coinToss():Boolean{
return ((next(2) == 0));
}
public function range(_arg1:int, _arg2:int, _arg3:int=1):int{
var _local4:int;
_local4 = (_arg2 - _arg1);
if (_local4 > 0){
return ((next((1 + _local4), _arg3) + _arg1));
};
if (_local4 < 0){
return ((next((1 - _local4), _arg3) + _arg2));
};
return (_arg1);
}
}
}//package
Section 9
//Candidate (Candidate)
package {
public class Candidate {
public var count:int;
public var x:int;
public var y:int;
public function Candidate(_arg1:int, _arg2:int, _arg3:int):void{
x = _arg1;
y = _arg2;
count = _arg3;
}
public function toString():String{
return ((((((("Candidate(x=" + x) + ", y=") + y) + " count=") + count) + ")"));
}
}
}//package
Section 10
//Canvas (Canvas)
package {
import flash.geom.*;
import flash.display.*;
import flash.utils.*;
public class Canvas extends Sprite {
private const imageCls:Class;
private const ERASE_STEP:int = 2;
private const ERASE_COUNT:int = 10;
private var eraseCount:int;
private var prevMap:ByteArray;
private var bitmap:Bitmap;
public var map:Map;
private var eraseBitmap:Bitmap;
private var idle:Boolean;
private var srcImage:BitmapData;
public static const areaHeight:int = 32;
public static const numColors:int = 5;
public static const areaWidth:int = 32;
public function Canvas():void{
imageCls = Canvas_imageCls;
super();
bitmap = new Bitmap();
addChild(bitmap);
srcImage = (new imageCls() as Bitmap).bitmapData;
}
public function get isIdle():Boolean{
return (idle);
}
public function setMap(_arg1:Map):void{
var _local2:int;
map = _arg1;
bitmap.bitmapData = new BitmapData((_arg1.width * areaWidth), (_arg1.height * areaHeight));
prevMap = new ByteArray();
prevMap.length = (_arg1.width * _arg1.height);
_local2 = 0;
while (_local2 < prevMap.length) {
prevMap[_local2] = 0xFF;
_local2++;
};
eraseCount = 0;
idle = true;
redraw();
}
public function erase(_arg1:int, _arg2:int):int{
var _local3:int;
if (!idle){
return (0);
};
map.unmark();
_local3 = map.mark(_arg1, _arg2);
if (_local3 < 2){
return (0);
};
createEraseBitmap();
map.erase();
redraw();
eraseCount = ERASE_COUNT;
idle = false;
return (_local3);
}
public function update():void{
if (!idle){
if (eraseCount > 0){
if ((eraseCount % ERASE_STEP) == 0){
eraseBitmap.visible = !(eraseBitmap.visible);
};
eraseCount--;
if (eraseCount == 0){
removeChild(eraseBitmap);
eraseBitmap = null;
};
} else {
if (!map.truncateStep()){
idle = true;
};
redraw();
};
};
}
private function createEraseBitmap():void{
var _local1:int;
var _local2:int;
var _local3:int;
var _local4:int;
var _local5:int;
var _local6:int;
var _local7:int;
var _local8:int;
var _local9:int;
_local1 = map.width;
_local2 = map.height;
_local3 = 0;
_local4 = 0;
_local6 = 0;
while (_local6 < map.width) {
_local5 = 0;
while (_local5 < map.width) {
if ((map.getItem(_local5, _local6) & Map.MARK) != 0){
if (_local5 < _local1){
_local1 = _local5;
};
if (_local5 > _local3){
_local3 = _local5;
};
if (_local6 < _local2){
_local2 = _local6;
};
if (_local6 > _local4){
_local4 = _local6;
};
};
_local5++;
};
_local6++;
};
_local7 = ((_local3 + 1) - _local1);
_local8 = ((_local4 + 1) - _local2);
eraseBitmap = new Bitmap(new BitmapData((_local7 * areaWidth), (_local8 * areaHeight), true, 0));
_local6 = 0;
while (_local6 < map.width) {
_local5 = 0;
while (_local5 < map.width) {
_local9 = map.getItem((_local5 + _local1), (_local6 + _local2));
if ((_local9 & Map.MARK) != 0){
_local9 = (_local9 & ~(Map.MARK));
if (_local9 > 0){
eraseBitmap.bitmapData.copyPixels(srcImage, new Rectangle((_local9 * areaWidth), 0, areaWidth, areaHeight), new Point((_local5 * areaWidth), (_local6 * areaHeight)));
};
};
_local5++;
};
_local6++;
};
eraseBitmap.x = (_local1 * areaWidth);
eraseBitmap.y = (_local2 * areaHeight);
addChild(eraseBitmap);
}
public function redraw():void{
var _local1:int;
var _local2:int;
var _local3:int;
var _local4:int;
var _local5:int;
var _local6:int;
var _local7:Point;
var _local8:int;
_local1 = 0;
_local2 = 0;
while (_local2 < map.height) {
_local3 = 0;
while (_local3 < map.width) {
_local4 = map.getItem(_local3, _local2);
_local5 = 0;
if (_local4 > 0){
if (map.getItem(_local3, (_local2 - 1)) == _local4){
_local5 = (_local5 | 1);
};
if (map.getItem((_local3 + 1), _local2) == _local4){
_local5 = (_local5 | 2);
};
if (map.getItem(_local3, (_local2 + 1)) == _local4){
_local5 = (_local5 | 4);
};
if (map.getItem((_local3 - 1), _local2) == _local4){
_local5 = (_local5 | 8);
};
};
_local6 = (_local4 | (_local5 << 3));
if (prevMap[_local1] != _local6){
prevMap[_local1] = _local6;
_local7 = new Point((_local3 * areaWidth), (_local2 * areaHeight));
if ((_local4 & Map.MARK) == 0){
bitmap.bitmapData.copyPixels(srcImage, new Rectangle(0, 0, areaWidth, areaHeight), _local7);
} else {
bitmap.bitmapData.copyPixels(srcImage, new Rectangle(0, areaHeight, areaWidth, areaHeight), _local7);
};
_local8 = (_local4 & 7);
if (_local8 > 0){
bitmap.bitmapData.copyPixels(srcImage, new Rectangle((_local8 * areaWidth), (_local5 * areaHeight), areaWidth, areaHeight), _local7, null, null, true);
};
if ((_local4 & Map.MARK) != 0){
bitmap.bitmapData.copyPixels(srcImage, new Rectangle(0, (areaHeight * 2), areaWidth, areaHeight), _local7, null, null, true);
};
};
_local1++;
_local3++;
};
_local2++;
};
}
public function focus(_arg1:int, _arg2:int):int{
var _local3:int;
if (!idle){
return (-1);
};
map.unmark();
_local3 = map.mark(_arg1, _arg2);
redraw();
return (_local3);
}
}
}//package
Section 11
//Canvas_imageCls (Canvas_imageCls)
package {
import mx.core.*;
public class Canvas_imageCls extends BitmapAsset {
}
}//package
Section 12
//Game (Game)
package {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
public class Game extends Sprite {
private const castOffMsg:Array;
private var lose:int;// = 0
private var winLose:String;// = ""
private var opFunc:Function;// = null
private var canvas:Canvas;
private var map:Map;
private var scoreLabel:Bitmap;
private var level:int;// = 0
private var round:int;// = 0
private var click:Boolean;// = false
private var score:int;// = 0
private var medoi:Medoi;
private var rnd:BSDRandom;
private var caption:Bitmap;
private var win:int;// = 0
private var enemyScore:int;// = 0
public function Game():void{
rnd = new BSDRandom();
winLose = "";
win = 0;
lose = 0;
score = 0;
enemyScore = 0;
round = 0;
level = 0;
click = false;
opFunc = null;
castOffMsg = ["……恥ずかしいんですけど", "……何じっと見てるんですか", "…………えっち", "……「」さんは変態です", "……ひどいですー(棒読み)", "……頭のコレは外しませんよ"];
super();
graphics.beginFill(4287012007);
graphics.drawRect(0, 0, 800, 600);
stage.scaleMode = StageScaleMode.NO_SCALE;
medoi = new Medoi(0);
medoi.y = 0;
medoi.x = 538;
addChild(medoi);
scoreLabel = new Bitmap();
scoreLabel.x = 48;
scoreLabel.y = 504;
addChild(scoreLabel);
showScore();
caption = new Bitmap();
caption.visible = false;
addChild(caption);
canvas = new Canvas();
canvas.x = 16;
canvas.y = 112;
addChild(canvas);
stage.addEventListener(MouseEvent.CLICK, clickMouse, false, 0, true);
addEventListener(Event.ENTER_FRAME, move, false, 0, true);
start();
}
private function movePlayer():void{
var turn:int;
var mx:int;
var my:int;
var focusCnt:int;
turn = 0;
mx = -2;
my = -2;
focusCnt = -1;
opFunc = function ():void{
var _local1:int;
var _local2:int;
var _local3:int;
if (canvas.isIdle){
if (turn == numTurns){
moveEnemy();
return;
};
if (map.isGameOver()){
nextLevel();
return;
};
_local2 = (canvas.mouseX / Canvas.areaWidth);
_local3 = (canvas.mouseY / Canvas.areaHeight);
if (!map.isAvail(_local2, _local3)){
_local2 = -1;
_local3 = -1;
};
if (((!((_local2 == mx))) || (!((_local3 == my))))){
mx = _local2;
my = _local3;
_local1 = canvas.focus(mx, my);
if (_local1 != focusCnt){
focusCnt = _local1;
if (focusCnt > 0){
showCaption((("……そこは" + calcScore(focusCnt, round)) + "点ですね"));
canvas.buttonMode = true;
} else {
showCaption((((("「」さんの" + (turn + 1)) + "手目ですよ……残り") + (numTurns - turn)) + "手です"));
canvas.buttonMode = false;
};
};
};
if (((click) && ((focusCnt > 0)))){
canvas.buttonMode = false;
_local1 = canvas.erase(mx, my);
if (_local1 > 0){
hideCaption();
score = (score + calcScore(_local1, round));
showScore();
turn++;
focusCnt = -1;
mx = -1;
};
};
};
canvas.update();
};
}
private function showCaption(_arg1:String):void{
var _local2:TextWriter;
_local2 = new TextWriter();
_local2.size = 24;
_local2.border = 1;
_local2.color = 4294967295;
_local2.borderColor = 4278190208;
caption.bitmapData = _local2.render(_arg1);
caption.x = (medoi.x - caption.width);
caption.y = ((canvas.y - caption.height) - 16);
caption.visible = true;
}
private function moveEnemy():void{
var thought:Thought;
var turn:int;
var waitMax:int;
var wait:int;
var cnt:int;
var fps:int;
var t0:int;
var thinking:Function;
var afterThink:Function;
var command:Function;
thinking = function ():void{
if (thought.think()){
stage.frameRate = fps;
opFunc = afterThink;
};
};
afterThink = function ():void{
if ((getTimer() - t0) >= 500){
opFunc = command;
};
};
command = function ():void{
var _local1:Candidate;
if (canvas.isIdle){
if (turn == numTurns){
round++;
showScore();
movePlayer();
} else {
_local1 = thought.getCommand(map, turn);
if (_local1 == null){
nextLevel();
} else {
if (wait == 0){
canvas.focus(_local1.x, _local1.y);
showCaption(((((turn + 1) + "手目は") + calcScore(_local1.count, round)) + "点です……"));
wait = waitMax;
} else {
wait--;
if (wait == 0){
canvas.erase(_local1.x, _local1.y);
enemyScore = (enemyScore + calcScore(_local1.count, round));
showScore();
turn++;
};
};
};
};
};
canvas.update();
};
thought = new Thought(map, round, win);
turn = 0;
waitMax = 12;
wait = 0;
if (map.isGameOver()){
nextLevel();
return;
};
fps = stage.frameRate;
stage.frameRate = 100;
showCaption("(……考え中……)");
t0 = getTimer();
opFunc = thinking;
}
private function hideCaption():void{
caption.bitmapData = null;
caption.visible = false;
}
private function startLevel():void{
var wait:int;
wait = 0;
if ((win + lose) < 5){
map = new Map(16, 12);
map.create(5);
canvas.setMap(map);
score = 0;
enemyScore = 0;
round = 1;
showScore();
showCaption((((win + lose) + 1) + "セット目です……"));
opFunc = function ():void{
if (wait < 25){
wait++;
} else {
movePlayer();
};
};
} else {
if (win > lose){
showCaption((((win + "対") + lose) + "で「」さんの勝ちです\n………ご褒美なんかありませんからね"));
} else {
showCaption((((win + "対") + lose) + "で「」さんの負けです\n……さあハロワに行きましょうね"));
};
opFunc = function ():void{
if (wait < 150){
wait++;
if (wait == 150){
showCaption("クリックするとリプレイです……");
};
} else {
if (click){
start();
};
};
};
};
}
private function start():void{
winLose = "";
win = 0;
lose = 0;
level = 0;
medoi.imageIndex = 0;
startLevel();
}
private function nextLevel():void{
var wait:int;
wait = 50;
if (score > enemyScore){
showCaption("「」さんの勝ちですか……");
} else {
if (score == enemyScore){
showCaption("同点……めどいので「」さんの勝ちでいいです");
} else {
showCaption("「」さんの負けですよ……");
};
};
if (score >= enemyScore){
win++;
winLose = (winLose + " ○");
} else {
lose++;
winLose = (winLose + " ×");
};
showScore();
level++;
opFunc = function ():void{
if (wait > 0){
wait--;
return;
};
if (score >= enemyScore){
castOff();
} else {
startLevel();
};
};
}
private function showScore():void{
var _local1:String;
var _local2:TextWriter;
_local1 = ((((("Round " + round) + " 「」:") + score) + " めどい:") + enemyScore);
_local1 = (_local1 + ("\n\nResult: " + winLose));
_local2 = new TextWriter();
_local2.size = 24;
_local2.border = 1;
_local2.color = 4294967295;
_local2.borderColor = 4278190208;
scoreLabel.bitmapData = _local2.render(_local1);
}
private function get numTurns():int{
return (((round > 3)) ? 3 : round);
}
private function castOff():void{
var n:int;
var wait:int;
var med:Medoi;
n = rnd.next(castOffMsg.length);
showCaption(castOffMsg[n]);
wait = 0;
med = new Medoi(medoi.imageIndex);
medoi.imageIndex = win;
med.x = medoi.x;
med.y = medoi.y;
addChild(med);
opFunc = function ():void{
wait++;
if (wait > 75){
removeChild(med);
startLevel();
} else {
if (wait == 50){
hideCaption();
} else {
if (wait > 50){
med.alpha = ((75 - wait) / 25);
};
};
};
};
}
private function move(_arg1:Event):void{
if (opFunc != null){
opFunc();
};
click = false;
}
private function clickMouse(_arg1:Event):void{
click = true;
}
public static function calcScore(_arg1:int, _arg2:int):int{
_arg1 = (_arg1 - 2);
_arg1 = (_arg1 * _arg1);
_arg1 = (_arg1 * _arg2);
return (_arg1);
}
}
}//package
Section 13
//Map (Map)
package {
import flash.geom.*;
import flash.utils.*;
public class Map {
private var remainCount:int;
private var mapWidth:int;
private var mapHeight:int;
private var map:ByteArray;
public static const MARK:uint = 128;
public function Map(_arg1:int, _arg2:int):void{
mapWidth = _arg1;
mapHeight = _arg2;
map = new ByteArray();
map.length = (_arg1 * _arg2);
remainCount = (_arg1 * _arg2);
}
public function getMaxCount(_arg1:Rectangle=null):int{
var _local2:int;
var _local3:int;
var _local4:int;
var _local5:int;
if (_arg1 == null){
_arg1 = new Rectangle(0, 0, mapWidth, mapHeight);
};
unmark();
_local2 = 0;
_local3 = _arg1.y;
while (_local3 < _arg1.bottom) {
_local4 = _arg1.x;
while (_local4 < _arg1.right) {
_local5 = mark(_local4, _local3);
if (_local5 > _local2){
_local2 = _local5;
};
_local4++;
};
_local3++;
};
unmark();
return (_local2);
}
public function getItem(_arg1:int, _arg2:int):int{
if (isAvail(_arg1, _arg2)){
return (map[(_arg1 + (_arg2 * mapWidth))]);
};
return (0);
}
public function truncateStep():Boolean{
var _local1:Boolean;
var _local2:int;
var _local3:int;
var _local4:int;
_local1 = false;
_local2 = 0;
while (_local2 < mapWidth) {
_local3 = (mapHeight - 1);
while (_local3 > 0) {
if (getItem(_local2, _local3) == 0){
_local4 = getItem(_local2, (_local3 - 1));
if (_local4 != 0){
setItem(_local2, _local3, _local4);
setItem(_local2, (_local3 - 1), 0);
_local1 = true;
};
};
_local3--;
};
_local2++;
};
if (_local1){
return (true);
};
_local2 = 0;
while (_local2 < (mapWidth - 1)) {
if ((((getItem(_local2, (mapHeight - 1)) == 0)) && (!((getItem((_local2 + 1), (mapHeight - 1)) == 0))))){
_local3 = (mapHeight - 1);
while (_local3 >= 0) {
_local4 = getItem((_local2 + 1), _local3);
if (_local4 == 0){
break;
};
setItem(_local2, _local3, _local4);
setItem((_local2 + 1), _local3, 0);
_local1 = true;
_local3--;
};
};
_local2++;
};
return (_local1);
}
private function setItem(_arg1:int, _arg2:int, _arg3:int):void{
if (isAvail(_arg1, _arg2)){
map[(_arg1 + (_arg2 * mapWidth))] = _arg3;
};
}
public function truncateAll():void{
var _local1:int;
var _local2:int;
var _local3:int;
var _local4:int;
_local1 = 0;
while (_local1 < mapWidth) {
_local4 = (mapHeight - 1);
_local2 = (mapHeight - 1);
while (_local2 >= 0) {
_local3 = getItem(_local1, _local2);
if (_local3 != 0){
if (_local4 != _local2){
setItem(_local1, _local4, _local3);
};
_local4--;
};
_local2--;
};
while (_local4 >= 0) {
setItem(_local1, _local4, 0);
_local4--;
};
_local1++;
};
_local4 = 0;
_local1 = 0;
while (_local1 < mapWidth) {
if (getItem(_local1, (mapHeight - 1)) != 0){
if (_local4 != _local1){
_local2 = 0;
while (_local2 < mapHeight) {
setItem(_local4, _local2, getItem(_local1, _local2));
_local2++;
};
};
_local4++;
};
_local1++;
};
while (_local4 < mapWidth) {
_local2 = 0;
while (_local2 < mapHeight) {
setItem(_local4, _local2, 0);
_local2++;
};
_local4++;
};
}
public function mark(_arg1:int, _arg2:int):int{
var c:int;
var mark:int;
var cnt:int;
var search:Function;
var x = _arg1;
var y = _arg2;
search = function (_arg1:int, _arg2:int):int{
if (getItem(_arg1, _arg2) != c){
return (0);
};
setItem(_arg1, _arg2, mark);
return (((((search((_arg1 - 1), _arg2) + search((_arg1 + 1), _arg2)) + search(_arg1, (_arg2 - 1))) + search(_arg1, (_arg2 + 1))) + 1));
};
c = getItem(x, y);
if ((((c == 0)) || (!(((c & MARK) == 0))))){
return (0);
};
mark = (c | MARK);
cnt = search(x, y);
if (cnt >= 2){
return (cnt);
};
setItem(x, y, c);
return (0);
}
public function clone():Map{
var _local1:Map;
var _local2:int;
_local1 = new Map(mapWidth, mapHeight);
_local2 = 0;
while (_local2 < map.length) {
_local1.map[_local2] = map[_local2];
_local2++;
};
return (_local1);
}
public function get width():int{
return (mapWidth);
}
public function isAvail(_arg1:int, _arg2:int):Boolean{
return ((((((((_arg1 >= 0)) && ((_arg2 >= 0)))) && ((_arg1 < mapWidth)))) && ((_arg2 < mapHeight))));
}
public function erase():Rectangle{
var _local1:int;
var _local2:int;
var _local3:int;
var _local4:int;
var _local5:int;
var _local6:int;
_local1 = mapWidth;
_local2 = 0;
_local3 = 0;
_local4 = 0;
_local5 = 0;
while (_local5 < mapHeight) {
_local6 = 0;
while (_local6 < mapWidth) {
if ((map[_local4] & MARK) != 0){
map[_local4] = 0;
if (_local6 < _local1){
_local1 = _local6;
};
if (_local6 > _local2){
_local2 = _local6;
};
if (_local5 > _local3){
_local3 = _local5;
};
};
_local6++;
_local4++;
};
_local5++;
};
if (_local1 > _local2){
return (new Rectangle(0, 0, 0, 0));
};
_local1--;
if (_local1 < 0){
_local1 = 0;
};
_local2 = (_local2 + 2);
if (_local2 > mapWidth){
_local2 = mapWidth;
};
_local3++;
if (_local3 > mapHeight){
_local3 = mapHeight;
};
return (new Rectangle(_local1, 0, (_local2 - _local1), _local3));
}
public function get height():int{
return (mapHeight);
}
public function getCandidates(_arg1:Rectangle=null):Array{
var ar:Array;
var y:int;
var cmp:Function;
var x:int;
var cnt:int;
var area = _arg1;
cmp = function (_arg1:Candidate, _arg2:Candidate):int{
if (_arg1.count > _arg2.count){
return (-1);
};
if (_arg1.count < _arg2.count){
return (1);
};
return (0);
};
ar = new Array();
if (area == null){
area = new Rectangle(0, 0, mapWidth, mapHeight);
};
unmark();
y = area.y;
while (y < area.bottom) {
x = area.x;
while (x < area.right) {
cnt = mark(x, y);
if (cnt >= 2){
ar.push(new Candidate(x, y, cnt));
};
x = (x + 1);
};
y = (y + 1);
};
unmark();
ar.sort(cmp);
return (ar);
}
public function get remain():int{
return (remainCount);
}
public function unmark():void{
var _local1:int;
_local1 = 0;
while (_local1 < map.length) {
map[_local1] = (map[_local1] & ~(MARK));
_local1++;
};
}
public function isGameOver():Boolean{
var _local1:int;
var _local2:int;
unmark();
_local1 = 0;
while (_local1 < mapHeight) {
_local2 = 0;
while (_local2 < mapWidth) {
if (mark(_local2, _local1) >= 2){
unmark();
return (false);
};
_local2++;
};
_local1++;
};
unmark();
return (true);
}
public function create(_arg1:int, _arg2:BSDRandom=null):void{
var _local3:int;
var _local4:*;
var _local5:*;
if (_arg2 == null){
_arg2 = new BSDRandom();
};
_local3 = 0;
while (_local3 < map.length) {
map[_local3] = ((_local3 % _arg1) + 1);
_local3++;
};
do {
_local3 = 0;
while (_local3 < map.length) {
_local4 = _arg2.next(map.length);
_local5 = map[_local3];
map[_local3] = map[_local4];
map[_local4] = _local5;
_local3++;
};
} while (isGameOver());
}
}
}//package
Section 14
//Medoi (Medoi)
package {
import flash.geom.*;
import flash.display.*;
public class Medoi extends Bitmap {
private var index:int;
private static const imgHeight:int = 600;
private static const srcCls:Class = Medoi_srcCls;
private static const imgWidth:int = 300;
private static const stripHeight:int = 4;
private static var img:Array = null;
public function Medoi(_arg1:int=0):void{
super(getImage(_arg1));
index = _arg1;
}
public function get imageIndex():int{
return (index);
}
public function set imageIndex(_arg1:int):void{
if (_arg1 >= numImages){
_arg1 = (numImages - 1);
};
bitmapData = getImage(_arg1);
index = _arg1;
}
public static function init():void{
var _local1:BitmapData;
var _local2:BitmapData;
var _local3:int;
var _local4:int;
var _local5:int;
var _local6:int;
var _local7:int;
var _local8:int;
var _local9:BitmapData;
if (img != null){
return;
};
_local1 = (new srcCls() as Bitmap).bitmapData;
_local2 = new BitmapData(_local1.width, _local1.height);
_local6 = (_local1.height / stripHeight);
_local5 = 0;
_local4 = 0;
while (_local4 < _local1.height) {
_local5 = ((_local5 + 12277) % _local6);
_local2.copyPixels(_local1, new Rectangle(0, (_local5 * stripHeight), _local1.width, stripHeight), new Point(0, _local4));
_local4 = (_local4 + stripHeight);
};
_local1.dispose();
_local7 = (_local2.width / imgWidth);
_local8 = (_local2.height / imgHeight);
img = new Array();
_local4 = 0;
while (_local4 < _local8) {
_local3 = 0;
while (_local3 < _local7) {
_local9 = new BitmapData(imgWidth, imgHeight);
_local9.copyPixels(_local2, new Rectangle((_local3 * imgWidth), (_local4 * imgHeight), imgWidth, imgHeight), new Point(0, 0));
img.push(_local9);
_local3++;
};
_local4++;
};
_local2.dispose();
}
public static function getImage(_arg1:int):BitmapData{
init();
if ((((_arg1 >= 0)) && ((_arg1 < img.length)))){
return (img[_arg1]);
};
return (null);
}
public static function get numImages():int{
init();
return (img.length);
}
}
}//package
Section 15
//Medoi_srcCls (Medoi_srcCls)
package {
import mx.core.*;
public class Medoi_srcCls extends BitmapAsset {
}
}//package
Section 16
//TextWriter (TextWriter)
package {
import flash.geom.*;
import flash.display.*;
import flash.text.*;
public class TextWriter {
public var size:Number;// = 24
public var color:uint;// = 4294967295
public var bold:Boolean;// = true
public var border:int;// = 1
public var font:String;// = "_等幅"
public var italic:Boolean;// = false
public var underline:Boolean;// = false
public var borderColor:uint;// = 4278190080
public function TextWriter(){
color = 4294967295;
border = 1;
borderColor = 4278190080;
size = 24;
font = "_等幅";
bold = true;
italic = false;
underline = false;
super();
}
private function makeBorder(_arg1:BitmapData, _arg2:int):BitmapData{
var _local3:BitmapData;
var _local4:BitmapData;
var _local5:int;
var _local6:int;
var _local7:int;
_local3 = _arg1.clone();
_local5 = ((_arg2 * 2) + 1);
_local6 = 1;
while (_local6 < _local5) {
_local7 = (_local5 - _local6);
if (_local7 > _local6){
_local7 = _local6;
};
_local3.copyPixels(_arg1, new Rectangle(0, 0, (_arg1.width - _local7), _arg1.height), new Point(_local7, 0), null, null, true);
_local6 = (_local6 + _local7);
_local4 = _arg1;
_arg1 = _local3;
_local3 = _local4;
};
_local6 = 1;
while (_local6 < _local5) {
_local7 = (_local5 - _local6);
if (_local7 > _local6){
_local7 = _local6;
};
_local3.copyPixels(_arg1, new Rectangle(0, 0, _arg1.width, (_arg1.height - _local7)), new Point(0, _local7), null, null, true);
_local6 = (_local6 + _local7);
_local4 = _arg1;
_arg1 = _local3;
_local3 = _local4;
};
_local3.dispose();
return (_arg1);
}
public function render(_arg1:String):BitmapData{
var _local2:TextField;
var _local3:int;
var _local4:int;
var _local5:Matrix;
var _local6:BitmapData;
_local2 = new TextField();
_local2.autoSize = TextFieldAutoSize.LEFT;
_local2.selectable = false;
_local2.defaultTextFormat = new TextFormat(font, size, ((border > 0)) ? borderColor : color, bold, italic, underline);
_local2.text = _arg1;
_local3 = ((Math.ceil(_local2.textWidth) + (border * 2)) + 4);
_local4 = ((Math.ceil(_local2.textHeight) + (border * 2)) + 4);
_local5 = null;
_local6 = new BitmapData(_local3, _local4, true, 0);
if (border > 0){
_local6.draw(_local2);
_local6 = makeBorder(_local6, border);
_local2.textColor = color;
_local5 = new Matrix(1, 0, 0, 1, border, border);
};
_local6.draw(_local2, _local5);
return (_local6);
}
}
}//package
Section 17
//Thought (Thought)
package {
import flash.geom.*;
public class Thought {
private const HIGHEST:int;
private var checkPlayer:Boolean;
private var round:int;
private var list0:Array;
private var map0:Map;
private var limit2:Array;
private var command:Array;
private var index0:int;
private var high:int;// = 0
private var limit:Array;
private var turn:int;
public function Thought(_arg1:Map, _arg2:int, _arg3:int):void{
HIGHEST = (1 << 30);
high = 0;
super();
turn = _arg2;
if (turn >= 3){
turn = 3;
};
switch (_arg3){
case 0:
limit = [2, 2, 1];
limit2 = [0, 0, 0];
checkPlayer = false;
break;
case 1:
limit = [2, 2, 1];
limit2 = [0, 3, 2];
checkPlayer = false;
break;
case 2:
limit = [4, 3, 1];
limit2 = [0, 4, 3];
checkPlayer = false;
break;
case 3:
limit = [8, 3, 1];
limit2 = [0, 6, 4];
checkPlayer = true;
break;
case 4:
default:
limit = [16, 4, 2];
limit2 = [0, 8, 8];
checkPlayer = true;
break;
};
map0 = _arg1;
list0 = _arg1.getCandidates();
if (list0.length > limit[0]){
list0.length = limit[0];
};
round = _arg2;
index0 = 0;
command = new Array();
}
public function getCommand(_arg1:Map, _arg2:int):Candidate{
var _local3:Array;
var _local4:Candidate;
if (_arg2 < command.length){
_local4 = command[_arg2];
_arg1.unmark();
if (_arg1.mark(_local4.x, _local4.y) > 0){
return (_local4);
};
};
_arg1.unmark();
_local3 = _arg1.getCandidates();
if (_local3.length == 0){
return (null);
};
return (_local3[0]);
}
public function think():Boolean{
var _local1:Candidate;
var _local2:Map;
var _local3:Rectangle;
if (index0 >= list0.length){
return (true);
};
_local1 = list0[index0];
_local2 = map0.clone();
_local2.mark(_local1.x, _local1.y);
_local3 = _local2.erase();
_local2.truncateAll();
if (think1(_local2, 1, _local3, Game.calcScore(_local1.count, round))){
command[0] = list0[index0];
};
index0++;
return (false);
}
private function think1(_arg1:Map, _arg2:int, _arg3:Rectangle, _arg4:int):Boolean{
var _local5:Boolean;
var _local6:int;
var _local7:Array;
var _local8:Candidate;
var _local9:int;
var _local10:int;
var _local11:Rectangle;
var _local12:Map;
_local5 = false;
if (_arg2 == turn){
if (checkPlayer){
_local6 = _arg1.getMaxCount();
if (_local6 > 0){
_local10 = Game.calcScore(_local6, (round + 1));
};
};
if ((_arg4 - _local10) > high){
high = (_arg4 - _local10);
return (true);
};
return (false);
};
_local7 = _arg1.getCandidates(_arg3);
if (_local7.length > limit2[_arg2]){
_local7.length = limit2[_arg2];
};
_local9 = 0;
while (_local9 < _local7.length) {
_local8 = _local7[_local9];
_local12 = _arg1.clone();
_local12.mark(_local8.x, _local8.y);
_local11 = _local12.erase();
_local12.truncateAll();
_local10 = (_arg4 + Game.calcScore(_local8.count, round));
if (think1(_local12, (_arg2 + 1), _local11, _local10)){
command[_arg2] = _local7[_local9];
_local5 = true;
};
_local9++;
};
_local7 = _arg1.getCandidates();
if (_local7.length > limit[_arg2]){
_local7.length = limit[_arg2];
};
_local9 = 0;
while (_local9 < _local7.length) {
_local8 = _local7[_local9];
_local12 = _arg1.clone();
_local12.mark(_local8.x, _local8.y);
_local11 = _local12.erase();
_local12.truncateAll();
_local10 = (_arg4 + Game.calcScore(_local8.count, round));
if (think1(_local12, (_arg2 + 1), _local11, _local10)){
command[_arg2] = _local7[_local9];
_local5 = true;
};
_local9++;
};
return (_local5);
}
}
}//package