我必须做一个我们需要实现mancala棋盘游戏的项目,然后为它实现AI.
我们已经被指示我们需要修改或更改minimax树以便能够与mancala一起工作,因为在游戏中玩家可以连续多次转弯.
我已经实现了我的游戏逻辑和GUI,但是在我开始使用AI之前,我想尝试一下它背后的理论.我在网上搜索了非转弯的迷你最大树,我似乎无法找到任何东西.但是我看到很多人都在谈论使用minimax来制造mancala.
现在我理解了正常的minimax树以及每个级别如何在最小节点和最大节点之间交替.有了我现在需要的树,我会说: min > max > max > min > max如果第二个玩家得到两个转弯?
我们还需要能够指定Minimax树的给定层深度.我们还需要进行alpha beta修剪,但是一旦我实际拥有一棵树,那就是以后的修剪.
algorithm artificial-intelligence minimax alpha-beta-pruning
我有asp.net自动生成的以下控制器
//
// POST: /Account/LogOff
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult LogOff()
{
AuthenticationManager.SignOut();
return RedirectToAction("Index", "Home");
}
Run Code Online (Sandbox Code Playgroud)
现在我有一个注销按钮.目前它看起来像这样:
<div class="userdrop">
<ul>
<li><a href="@Url.Action("Manage", "Account")">Profile</a></li>
<li><a href="@Url.Action("LogOff", "Account")">Logout</a></li>
</ul>
</div><!--userdrop-->
Run Code Online (Sandbox Code Playgroud)
但它不起作用,我猜它是因为它是一个Post动作方法.
我怎么去"退出"?
[编辑]
为什么它会自动生成为Http Post?这样更安全吗?它在注销时是否不随身携带cookie?
我已经实现了一个 dialogFragment,它显示了一条简单的消息:
private static DialogFragment loadingDialogFragment = null;
public void showLoadingDialog(String title, String message) {
loadingDialogFragment = new LoadingDialogFragment();
Bundle args = new Bundle();
args.putString("title", title);
args.putString("message", message);
loadingDialogFragment.setArguments(args);
loadingDialogFragment.show(fragManager, "loadingDialog");
}
public void dismissLoadingDialog() {
if (loadingDialogFragment != null) {
loadingDialogFragment.dismiss();
}
}
Run Code Online (Sandbox Code Playgroud)
但是,如果显示对话框并且我旋转屏幕,则我的 dissmisslaodingDialog 不起作用。我认为这是因为当您旋转时,它会再次调用 on create 函数并丢失对对话框的引用,但我已将其设为静态。
上面的代码放在一个 Utility 类中,我从我的活动中调用它,如下所示:
util.showLoadingDialog("Loading", "");
SendCommand(deviceId, "Command");
Run Code Online (Sandbox Code Playgroud)
然后我调用utils.dismissLoadingDialogSendCommmand 的回调函数。
我在这里缺少什么?
{编辑}
我的活动片段中的代码
util.showLoadingDialog("Loading", "");
SendCommand(deviceId, "Command");
public void SendCommand(int deviceId, final String command) {
Network.get(mContext, "/" + command …Run Code Online (Sandbox Code Playgroud) android android-fragments android-dialog android-dialogfragment
我有一个Web API,它向执行某些任务/命令的Windows服务发出HTTP请求.
如果我的'service'抛出异常,那么我想使用JSON将该异常传递回Web API.然后我想将异常反序列化回异常对象并抛出它.
我的代码:
Web API和服务之间的共享异常:
public class ConnectionErrorException : Exception
{
public ConnectionErrorException()
{
}
public ConnectionErrorException(String message)
: base(message)
{
}
}
Run Code Online (Sandbox Code Playgroud)
现在在我的服务中,我有以下代码:
...
try
{
result = await ExecuteCommand(userId);
//If reached here nothing went wrong, so can return an OK result
await p.WriteSuccessAsync();
}
catch (Exception e)
{
//Some thing went wrong. Return the error so they know what the issue is
result = e;
p.WriteFailure();
}
//Write the body of the response:
//If the result …Run Code Online (Sandbox Code Playgroud) 我是LINQ的新手,
我想从dbcontext生成一个对象列表,其中某个字段设置为true.
这是我到目前为止,但我得到一个关于选择的错误?
using (var db = new dbContext())
{
return (from s in db.sims.Where(x=>x.has_been_modified == true) select x).ToList();
}
Run Code Online (Sandbox Code Playgroud)
编辑:
//Returns a list of entries which where marked as edited in the sim managment database
private List<String> GetUpdatedEntries()
{
using (var db = new dbContext())
{
return db.sims.Where(x => x.has_been_modified).ToList();
}
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试获取IList<ApplicationRole>用户当前注册的角色.
现在在Usermanager类中,我看到有一个函数调用IList<String> usersRoles = userManager.GetRoles(id);但它只是将Role的名称作为字符串返回.这并不能帮助我,我需要的id,name和description中的作用.
我怎样才能进行类似的调用但是收到applicationRole而不是字符串?
这是我的模特:
public class ApplicationRole : IdentityRole
{
[Display(Name = "Description")]
[StringLength(100, MinimumLength = 5)]
public string Description { get; set; }
}
Run Code Online (Sandbox Code Playgroud) asp.net asp.net-mvc user-roles asp.net-mvc-5 asp.net-identity
我正忙着用asp.net web api设计一个web服务.我想开始对每个控制器进行单元测试.
到目前为止,这是我的测试类:
[TestClass]
public class MyDevicesControllerTest
{
[TestMethod]
public void TestValidUser()
{
MyDeviceController controller = new MyDeviceController();
var result = controller.Get();
}
[TestMethod]
public void TestInvalidUser()
{
MyDeviceController controller = new MyDeviceController();
var result = controller.Get();
}
}
Run Code Online (Sandbox Code Playgroud)
但我的Web服务使用令牌身份验证.所以我有些人需要模拟身份验证过程.
所以我想我可能不会让用户通过Http请求进行测试吗?即,而不是测试控制器我只是做一个http请求并检查其答案?
测试它的更简单/更好的方法是什么?
我正在使用请求上下文来获取名为"token"的标头的值.
var token = context.request.Headers.GetValues("Token")
Run Code Online (Sandbox Code Playgroud)
现在如果标题存在.这一切都可以工作数百个,但是现在如果标头不存在,我希望它返回null.但它会引发异常System.InvalidOperationExecption
我唯一的选择是试一试吗?
我有以下几点:
public override Task<SignInStatus> PasswordSignInAsync(string userName, string password, bool isPersistent, bool shouldLockout)
{
return base.PasswordSignInAsync(userName, password, isPersistent, shouldLockout);
}
Run Code Online (Sandbox Code Playgroud)
我想将其修改为以下内容:
public override Task<SignInStatus> PasswordSignInAsync(string userName, string password, bool isPersistent, bool shouldLockout)
{
var result = base.PasswordSignInAsync(userName, password, isPersistent, shouldLockout);
//If status was successful do some thing here
if(result = success)
{
//update last logged in time.
}
//Lastly return the result
return result;
}
Run Code Online (Sandbox Code Playgroud)
现在我想修改函数的功能.
我想执行基本任务,然后使用它的结果在我的重写函数中做一些事情?
我怎样才能做到这一点?
我正在尝试检查非活动类的互联网连接.
我使用以下代码:
public boolean isNetworkAvailable() {
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = cm.getActiveNetworkInfo();
if (networkInfo != null && networkInfo.isConnected()) {
return true;
}
return false;
}
Run Code Online (Sandbox Code Playgroud)
但是下面的代码行用红色加下划线:
getSystemService(Context.CONNECTIVITY_SERVICE)
Run Code Online (Sandbox Code Playgroud)
我假设它是因为它无法获得systemService.我怎样才能获得系统服务?
c# ×5
asp.net-mvc ×3
android ×2
asp.net ×2
algorithm ×1
async-await ×1
exception ×1
html-helper ×1
http-headers ×1
json ×1
json.net ×1
linq ×1
minimax ×1
overriding ×1
user-roles ×1