Beispiel #1
0
        public CAnalyzeResult Analyze(EPlayer player, int depth)
        {
            if (depth <= 0)
            {
                throw new ArgumentException($"Значение параметра \"{nameof(depth)}\" должен быть больше 0");
            }

            var   maxMark    = double.NegativeInfinity;
            CMove maxMove    = null;
            var   iterations = 0;

            foreach (var move in GetMoves(player))
            {
                //Делаем ход
                move.Do();

                var mark = GetMark(player, depth, ref iterations);
                if (maxMark < mark)
                {
                    maxMark = mark;
                    maxMove = move;
                }

                //Откатываем ход
                move.Undo();
            }

            return(new CAnalyzeResult(maxMove, maxMark, iterations));
        }
Beispiel #2
0
        public void Do(CMove move)
        {
            _history.RemoveRange(_historyIndex + 1, _history.Count - _historyIndex - 1);
            _history.Add(move);

            Redo();
        }
Beispiel #3
0
 // protocol handles
 public override int ProcessCMove(CMove protocol)
 {
     Login.Session session = Login.Session.Get(protocol);
     // throw exception if not login
     GetBag(session.LoginRoleId.Value).Move(protocol.Argument.PositionFrom, protocol.Argument.PositionTo, protocol.Argument.Number);
     return(Zeze.Transaction.Procedure.Success);
 }
Beispiel #4
0
        public void CMove(GSSession session, CMove message)
        {
            var dirs = new List <Point>
            {
                new Point(-1, -1),
                new Point(0, -1),
                new Point(1, -1),

                new Point(1, 0),
                new Point(1, 1),
                new Point(0, 1),

                new Point(-1, 1),
                new Point(-1, 0)
            };

            var @char      = session.Player.Character;
            var count      = message.Path[0] & 0x0F;
            var solvedPath = new List <Point>();
            var Cpos       = new Point(message.X, message.Y);

            solvedPath.Add(Cpos);

            var valid = true;

            for (int i = 1; i <= count; i++)
            {
                var a = (message.Path[(i + 1) / 2] >> (((i % 2) == 1) ? 4 : 0)) & 0x0F;
                Cpos.Offset(dirs[a]);
                solvedPath.Add(Cpos);
                //Logger.Debug("Path solved [{0}] X:{1} Y:{2}", i, Cpos.X, Cpos.Y);
                var att = @char.Map.GetAttributes(Cpos);
                if (att.Where(y => y == Resources.Map.MapAttributes.NoWalk || y == Resources.Map.MapAttributes.Hide).Count() > 0)
                {
                    valid = false;
                }
            }

            if (!valid)
            {
                session.SendAsync(new SPositionSet {
                    Number = (ushort)session.Player.Account.ID.ShufleEnding(), X = (byte)@char.Position.X, Y = (byte)@char.Position.Y
                });
                Logger
                .ForAccount(session)
                .Error("Invalid path");
                return;
            }

            @char.Position = Cpos;

            session.SendAsync(new SMove((ushort)session.Player.Account.ID, (byte)Cpos.X, (byte)Cpos.Y, message.Path[0]));
        }
Beispiel #5
0
        public override void StartAction()
        {
            var move = new CMove();

            CCell cell = selected.cell.Clone();

            field.SetIconAt(targeted.cell, selected);
            field.SetIconAt(cell, targeted);

            move.AddMove(selected, field.GetIconCenterByCell(selected.cell));
            move.AddMove(targeted, field.GetIconCenterByCell(targeted.cell));

            move.SetObserver(this);
        }
Beispiel #6
0
        public override void StartAction()
        {
            move = new CMove();

            CGame.Sounds.fall.Play();

            for (int col = 0; col < field.width; col++)
            {
                ColumnFreeFall(col);
            }

            if (move.IsFinished())
            {
                ComplateAction();
            }
            else
            {
                move.SetObserver(this);
            }
        }
Beispiel #7
0
        private static EMoveResult MoveOrBreak(ICollection <CMove> listToAdd, CMoveItem fromItem, int file, int rank)
        {
            var piece   = fromItem.Piece;
            var partner = fromItem.Board[file, rank];
            var board   = fromItem.Board;

            if (partner == null)
            {
                //Ход без взятия
                var move = new CMove(
                    new[] { fromItem },
                    new[] { new CMoveItem(board, piece, file, rank) }
                    );

                listToAdd.Add(move);

                return(EMoveResult.Continue);
            }

            if (partner.Player != piece.Player)
            {
                //Ход со взятием
                var move = new CMove(
                    new[] { fromItem, new CMoveItem(board, partner, file, rank) },
                    new[] { new CMoveItem(board, piece, file, rank) }
                    );

                listToAdd.Add(move);

                if (partner.Type == EPieceType.King)
                {
                    return(EMoveResult.Return);
                }
            }

            return(EMoveResult.Break);
        }
Beispiel #8
0
 private void Do(CMove move)
 {
     _game.Do(move);
     Update();
 }
        public MainViewModel(ScriptContext context)
        {
            sc = context;

            DoAnonymizeStudyIDs = true;
            DoAnonymizeUIDs     = true;
            DateSettings        = ESAPIAnon.Settings.DateSettings.NULL_AGE;
            DoRemovePrivateTags = true;
            DoPlans             = DoStructures = DoDoses = DoImages = true;
            DoResendToDaemon    = false;
            FirstName           = "";
            LastName            = "";
            Id = "";

            AnonymizeCommand = new RelayCommand(() =>
            {
                //Get current patient id
                var id = GetPatientId();
                //Get current directory // Make patient folder if not exists
                var path = Helpers.AssemblyDirectory;
                var dir  = Path.Combine(path, id);
                if (!Directory.Exists(dir))
                {
                    Directory.CreateDirectory(dir);
                }
                //Read settings file
                var ip      = "100.75.16.108";
                var scpAE   = "Db Daemon";
                var scpPort = 104;

                UpdateStatus("Getting DICOM Files from the Daemon...");
                CMove.GenerateDicomFiles(sc.Patient.Id, ip, scpPort.ToString(), scpAE, dir);
                UpdateStatus("Anonymizing...");
                var files    = Directory.GetFiles(dir);
                var dcms     = files.ToList().Select(f => DICOMFileReader.Read(f)).ToList();
                var settings = AnonymizeSettings.Generate(this);
                var que      = AnonymizationQue.Build(settings, dcms);
                dcms.ForEach(d => que.Anonymize(d));

                //Let user choose output
                FolderBrowserDialog fbd = new FolderBrowserDialog();
                fbd.Description         = "Select DICOM File destination folder";
                fbd.RootFolder          = Environment.SpecialFolder.Desktop;
                DialogResult result     = fbd.ShowDialog();
                if (result == DialogResult.OK)
                {
                    var output = fbd.SelectedPath;
                    int i      = 0;
                    foreach (var dcm in dcms)
                    {
                        var fileOut = Path.Combine(output, string.Format("{0}.dcm", i));
                        i++;
                        DICOMFileWriter.WriteLittleEndian(fileOut, dcm);
                    }

                    //Clean up directory
                    Directory.Delete(dir, true);
                    UpdateStatus("Complete!");
                }
                else
                {
                    System.Windows.MessageBox.Show("You must select a file location!");
                }
            });
        }
Beispiel #10
0
 public void setTarget(Transform target)
 {
     cMove = target.GetComponent <CMove>();
     cJump = target.GetComponent <CJump>();
 }
Beispiel #11
0
 public CAnalyzeResult(CMove bestMove, double bestMark, int iterations)
 {
     BestMove   = bestMove;
     BestMark   = bestMark;
     Iterations = iterations;
 }
Beispiel #12
0
        public static void archiveFolder(
            String rCloneDirectory,
            String localDropStream,
            String localArchiverBuffer,
            String remoteDropStreamTarget,
            String remoteArchive,
            String fileFormatNameRegex,
            String fileExtenstion,
            String thesholdInGigabytes)
        {
            Stopwatch watch = Stopwatch.StartNew();

            String localTempFolder     = String.Empty;
            String localZipDestination = String.Empty;


            try
            {
                ///Timer for diagnosing

                ///Let's get a temperary name for the temperary folder
                Logger.Info("Getting Temparary Folder... ");
                localTempFolder = Organizer.getTempFolderPath(localDropStream, localArchiverBuffer);
                Logger.Info(String.Format("{0} - {1}", "Temparary Folder Retrieved!", localTempFolder));

                ///Where will this zip file be located locally
                Logger.Info("Creating Time-Stamped folders...");
                localZipDestination = Organizer.createTimestampFolders(localDropStream, localArchiverBuffer, fileFormatNameRegex, fileExtenstion);
                Logger.Info(String.Format("{0}: {1}", "Time-Stamped folders created! Local Zip Destination", localZipDestination));

                ///Compress / Remove the folder to be archived
                Logger.Info(String.Format("{0}: {1}", "Compress and removing target folder to the following location", localTempFolder));
                Organizer.compressAndRemoveTargetFolder(localZipDestination);
                Logger.Info("Successfully compressed and removed folder!");


                ///To make the threshold process a little easier, we need to rename any duplicated file names
                Logger.Info(String.Format("{0}: {1}", "Renaming any duplicated files for removal", localTempFolder));
                CDirectory.renameDuplicatedFiles(rCloneDirectory, remoteArchive);
                Logger.Info("Duplicates renamed / removed!");

                ///Serialize localzipdesitination file for parsing
                FileInfo info = new FileInfo(localZipDestination);
                ///Get a list of all of the existing files in target archive
                var existingFiles = CloudDirectory.serializeDirectory(CDirectory.getFilesStatsInDirectory(rCloneDirectory, remoteArchive));
                ///Delete any files in cloud over threshold
                Logger.Info(String.Format("Removing any files over: {0} (GB) At remote Location: {1} Utilizing: {2}", thesholdInGigabytes, remoteArchive, info.Name));
                List <FileCloudInfo> filesToRemove = Containment.getFIlesInDirectoryOverThreshold(existingFiles, info, Double.Parse(thesholdInGigabytes));
                Logger.Info("Now removing a total of {0} files from cloud directory: {1}", filesToRemove.Count(), remoteArchive);
                Logger.Debug("Target Files: {0}", String.Concat(filesToRemove.Select(o => String.Format("\n{0} ", o.FilePath)))); //Print out all of the files to remove

                ///Run Command to Delete *any* target files
                filesToRemove.ForEach(i => CDelete.deleteDirectory(rCloneDirectory, String.Format(@"{0}/{1}", remoteArchive, i.FilePath)));
                ///Lots of logging, information regarding deleting items
                Logger.Info("Ran command to removed files over threshold! Files *removed*: {0} | Memory *Free'd up*: {1} (GB) ", filesToRemove.Count,
                            ByteSizeLib.ByteSize.FromBytes(filesToRemove.Sum(i => i.Length)).GigaBytes, (filesToRemove.Sum(i => i.Length)));

                ///Moving Zipped file to the cloud storage
                Logger.Info(String.Format("{0} - Local Temp Folder: {1} RemoteArchive: {2}", "Moving the compressed file to cloud storage!", localTempFolder, remoteArchive));
                CMove.moveFile(rCloneDirectory, localTempFolder, remoteArchive, Config.compressionFormat, Config.connectionAttempts);
                Logger.Info(String.Format("{0}", "Successfully deleted Contents!"));

                ///Delete the local folder
                Logger.Info(String.Format("{0}: {1}", "Deleting the following local 'Temp Folder' ", localTempFolder));
                System.IO.Directory.Delete(localTempFolder, true);
                Logger.Info("Successfully deleted the local temp folder!");

                ///TODO: Remove this to a later process...
                Logger.Info(String.Format("{0} - rCloneLocation: {1} gDriveName: {2}", "Deleting requested remote folders", rCloneDirectory, remoteDropStreamTarget));
                CDelete.deleteDirectory(rCloneDirectory, remoteDropStreamTarget);
                Logger.Info(String.Format("{0}", "Deletion of contents command has been ran!"));


                ///Due to a bug, the cloud software may not "release" files. Resetting it will fix this.

                Logger.Info(String.Format("{0} - cloudProcessName: {1} cloudProcessPath: {2}", "Restarting Process", Config.cloudProcessName, Config.cloudProcessPath));
                Management.restartProcess(Config.cloudProcessName, Config.cloudProcessPath);
                Logger.Info("Process successully restarted!");



                ///Delete the cloud folder
                Logger.Info(String.Format("{0} - rCloneLocation: {1} gDriveName: {2}", "Emptying Cloud Folder", rCloneDirectory, Config.driveProfileName));
                CDelete.emptyTrashFolder(rCloneDirectory, Config.driveProfileName);
                Logger.Info("Successfully emptied cloud recycle bin");

                Logger.Info(String.Format("{0} - Elasped time:{1}", "Archiver has successully been ran!", watch.Elapsed.ToString()));
            }

            catch (OrganizerException e)
            {
                Logger.Error(e, String.Format("{0} - {1} (Elapsed time before error: {2} ", "Error while prepping files before transfer", e.Message, watch.Elapsed.ToString()));
                Logger.Trace(e.StackTrace);
            }
            catch (Rclone_Move_Exception e)
            {
                Logger.Error(e, String.Format("{0} - {1} (Elapsed time before error: {2}", "Error while transfering file to the cloud", e.Message, watch.Elapsed.ToString()));
                Logger.Trace(e.StackTrace);
            }

            catch (Exception e)
            {
                Logger.Error(e, String.Format("{0} - {1} (Elapsed time before error: {2} ", "Error while Archiving", e.Message, watch.Elapsed.ToString()));
                Logger.Trace(e.StackTrace);
            }

            finally
            {
                ///If the process fails, remove the temperary directory!
                if (Directory.Exists(localTempFolder))
                {
                    Directory.Delete(localTempFolder, true);
                }
            }
        }