My notes say that there are two main categories of thread scheduling algorithms, preemptive and time sharing. I'd like to clear up exactly how these work in Java. As I understand (and PLEASE correct me if I'm even slightly wrong!) preemptive allows a higher priority thread to take over the CPU from a lower priority thread when it enters the runnable state. Will it monopolize the CPU u
我的笔记说,有两种主要的线程调度算法类型,抢占式和时间共享。 我想清楚说明这些在Java中如何工作。 据我所知(如果我甚至有点错,请纠正我)抢占允许更高优先级的线程在进入可运行状态时从低优先级线程接管CPU。 它会垄断CPU,直到更高优先级的线程出现,或者它会消耗大部分CPU时间,但优先级较低的线程也有机会运行? 我在这里假设没有调用会放弃像yield()或sleep()这样的CPU的方法。 在时间共享中,更高优先级的
How to force stop an app using Java code? I'm trying to build a memory cleaner, that can help clean out background processes. What I mean by force stop is to make sure when you go to the app details, the FORCE STOP button is grey out. I know there is a way to kill the process of an app, but when you go to the running list, the app is still there even after you have killed it. And I have t
如何强制停止使用Java代码的应用程序? 我正在尝试构建一个内存清理程序,它可以帮助清理后台进程。 我强迫停止的意思是确保当你进入应用程序的细节时, FORCE STOP按钮是灰色的。 我知道有一种方法可以杀死应用程序的进程,但是当您进入运行列表时,即使杀死它,应用程序仍然存在。 我尝试了很多类似的内存清理应用程序,其中只有一个可以完全强制停止应用程序,但它有很多无用的通知 - 非常烦人。 PS:当你去Settings -&
This is one of my fragments that i am using in a navigation drawer. I need to add a button that when pressed, changes to a text box into different text. i keep getting errors that the findviewbyid()int cannot be resolved and such. I could get this working on MainActivity/activity_main, but when i use one of the pages of the nav drawer(like ConnectFragment.java/fragment_connect.xml), i get erro
这是我在导航抽屉中使用的片段之一。 我需要添加一个按钮,当按下时,将文本框更改为不同的文本。 我不断收到findviewbyid()int无法解析的错误等。 我可以在MainActivity / activity_main上工作,但是当我使用导航抽屉的某个页面(如ConnectFragment.java/fragment_connect.xml)时,出现错误。 这是仅用于ConnectFragment的代码 import android.os.Bundle; import android.os.PersistableBundle; import android.support
I have implemented the minimax algorithm here in my chess AI and I know it is not working properly because it just moves 1 piece back and forth over and over again. getPieces(true) returns all white pieces in the current board state getPieces(false) returns all black pieces in the current board state ChessPiece.getAllPotentialMoves() pretty self explanatory, gets all possible moves for a pa
我在我的国际象棋AI中实现了minimax算法,我知道它不能正常工作,因为它只是一遍又一遍地来回移动。 getPieces(true)返回当前板状态下的所有白色块 getPieces(false)返回当前板状态下的所有黑块 ChessPiece.getAllPotentialMoves()非常自我解释,为特定的片断获取所有可能的移动 PieceMovements.move()将块(p)移动到位置(m - >表示移动) PieceMovements.undo()解除了以前的移动 searchDepth是首次
I've made a negamax algorithm for a chess-like game and I want to know how to use the final board value result. I understand the final return of the negamax algorithm represents what the board value will be after the player takes his best possible move, but that isn't exactly useful information. I need to know what that move is, not what it's worth. Here's the code: public in
我为棋类游戏制定了negamax算法,我想知道如何使用最终的棋盘值。 我知道negamax算法的最终回报代表了玩家采取他最好的举动之后棋盘的价值,但这并非完全有用的信息。 我需要知道那个举措是什么,而不是它的价值。 代码如下: public int negamax(Match match, int depth, int alpha, int beta, int color) { if(depth == 0) { return color*stateScore(match); } ArrayList<Match> matches = ge
I just learned Android and Java programming (very noob inside), and I would like to ask some questions regarding android programming and Socket Server. I got an assignment to create a simple chess application (excluding the AI), the position of pawn will be retrieved from TCP socket in : Server : xinuc.org Port : 7387 I was told to use Socket Persistent because Server will update pawn'
我刚刚学习了Android和Java编程(内部很小心),并且我想问一些关于android编程和Socket服务器的问题。 我有一个任务来创建一个简单的国际象棋应用程序(不包括AI),pawn的位置将从TCP套接字检索 : 服务器:xinuc.org 港口:7387 我被告知使用Socket Persistent,因为Server会在每一秒更新典当的位置,典当的位置将以这种格式发送 [典当代码] [水平位置] [垂直位置] [空间], 典当代码: K:白色国王 问:白皇
I'm looking to create a basic chess (or failing that, checkers/draughts) engine. After researching the topic I'm fairly confident that I want to use a series of bitboards. I understand the concept at a basic level but I'm having trouble representing them in Java. I've attempted to represent the white pieces of a chessboard as 1 and everything else as 0 using a long: long whit
我期待创造一个基本的国际象棋(或失败者,跳棋/草稿)引擎。 在研究了这个话题之后,我相当确信我想要使用一系列的位面板。 我理解基本级别的概念,但在Java中表示它们时遇到问题。 我试图把棋子的白色棋子表示为1,而其他所有东西都用0表示: long whitePieces = 0000000000000000000000000000000000000000000000001111111111111111L; 但是当我打印出来时,我得到以下46位: System.out.println(Long.toBinaryString(whi
I'm attempting to move my console-based chess game to a GUI. I'm currently referencing the this chess tutorial to help get me started. I'm currently setting only one white rook on the board for testing purposes. In my console chess program, I have a Rook Class that determines how the Rook can move, what color it is, and so on. In the tutorial code, they add a piece to the board l
我试图将我的基于控制台的国际象棋游戏移至GUI。 我现在正在参考这个国际象棋教程,以帮助我开始。 为了测试目的,我目前只在电路板上设置一个白车。 在我的控制台国际象棋程序中,我有一个Rook Class,它决定了Rook如何移动,它是什么颜色,等等。 在教程代码中,他们添加了一块板子,如下所示: // Add a few pieces to the board JLabel piece = new JLabel("rl.png"); JPanel panel = (JPanel) chessBo
I am creating a chess game and I am now adding the pieces. All the pieces have rendered individually correctly, but now that I am trying to set them in their location they are not appearing where they should. What in my code is causing the pieces to generate wrong? public class Tile { Graphics g; public static HashMap<HashMap<Integer, Integer>, String> pieces = new HashMap<>
我正在创建一个国际象棋游戏,现在我正在添加这些棋子。 所有作品都单独呈现,但现在我试图将它们放置在它们的位置,但它们并未出现在应该出现的位置。 什么在我的代码导致片断产生错误? public class Tile { Graphics g; public static HashMap<HashMap<Integer, Integer>, String> pieces = new HashMap<>(); public Tile(Graphics g) { this.g = g; } public static void setPieceLoc(int x, in
I would like to move the piece using my mouse. For example, say there's a pawn sitting on a square on the chess board. If my mouse was to click (press and release) in the square that the pawn is in, it would be selected. Afterwards, I would click (press and release) in an appropriate square. Say, the square in front of it since that is a proper move in Chess. The pawn would move (get er
我想用我的鼠标移动一块。 例如,说棋盘上有一个棋子坐在广场上。 如果我的鼠标点击(按下并释放)棋子所在的方块,它将被选中。 之后,我会在适当的方块中点击(按下并释放)。 说,它在前面的广场,因为这是在国际象棋适当的举措。 棋子会移动(从原来的方块擦除,然后重新绘制新棋子)到最终选定的方块。 目前,当执行完成时,Pawn就坐在一个广场上。 如果有任何帮助,我正在使用Ready To Program Java(我的老师告