mirror of
https://github.com/tiennm99/caro.git
synced 2026-05-24 04:24:23 +00:00
增加机器决策类,作为机器出牌的决策者
This commit is contained in:
+25
@@ -0,0 +1,25 @@
|
||||
package org.nico.ratel.landlords.robot;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.nico.ratel.landlords.entity.Poker;
|
||||
import org.nico.ratel.landlords.entity.PokerSell;
|
||||
|
||||
/**
|
||||
* How does the machine decide on a better strategy to win the game
|
||||
*
|
||||
* @author nico
|
||||
*/
|
||||
public class RobotDecisionMakers {
|
||||
|
||||
public static List<Poker> howToPlayPokers(PokerSell lastPokerSell, List<Poker> myPokers){
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean howToChooseLandlord(List<Poker> leftPokers, List<Poker> rightPokers, List<Poker> landlordPokers, List<Poker> myPokers) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
+6
-1
@@ -3,8 +3,11 @@ package org.nico.ratel.landlords.server.robot;
|
||||
import java.util.Map;
|
||||
|
||||
import org.nico.ratel.landlords.entity.ClientSide;
|
||||
import org.nico.ratel.landlords.entity.Room;
|
||||
import org.nico.ratel.landlords.enums.ServerEventCode;
|
||||
import org.nico.ratel.landlords.helper.MapHelper;
|
||||
import org.nico.ratel.landlords.robot.RobotDecisionMakers;
|
||||
import org.nico.ratel.landlords.server.ServerContains;
|
||||
import org.nico.ratel.landlords.server.event.ServerEventListener;
|
||||
|
||||
public class RobotEventListener_CODE_GAME_LANDLORD_ELECT implements RobotEventListener{
|
||||
@@ -12,11 +15,13 @@ public class RobotEventListener_CODE_GAME_LANDLORD_ELECT implements RobotEventLi
|
||||
@Override
|
||||
public void call(ClientSide robot, String data) {
|
||||
|
||||
Room room = ServerContains.ROOM_MAP.get(robot.getRoomId());
|
||||
|
||||
Map<String, Object> map = MapHelper.parser(data);
|
||||
int turnClientId = (int) map.get("nextClientId");
|
||||
|
||||
if(turnClientId == robot.getId()) {
|
||||
ServerEventListener.get(ServerEventCode.CODE_GAME_LANDLORD_ELECT).call(robot, "TRUE");
|
||||
ServerEventListener.get(ServerEventCode.CODE_GAME_LANDLORD_ELECT).call(robot, String.valueOf(RobotDecisionMakers.howToChooseLandlord(robot.getPre().getPokers(), robot.getNext().getPokers(), room.getLandlordPokers(), robot.getPokers())));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+8
-11
@@ -1,24 +1,21 @@
|
||||
package org.nico.ratel.landlords.server.robot;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.nico.ratel.landlords.entity.ClientSide;
|
||||
import org.nico.ratel.landlords.enums.ServerEventCode;
|
||||
import org.nico.ratel.landlords.helper.MapHelper;
|
||||
import org.nico.ratel.landlords.server.event.ServerEventListener;
|
||||
import org.nico.ratel.landlords.entity.PokerSell;
|
||||
import org.nico.ratel.landlords.entity.Room;
|
||||
import org.nico.ratel.landlords.server.ServerContains;
|
||||
|
||||
public class RobotEventListener_CODE_GAME_POKER_PLAY implements RobotEventListener{
|
||||
|
||||
@Override
|
||||
public void call(ClientSide robot, String data) {
|
||||
Room room = ServerContains.ROOM_MAP.get(robot.getRoomId());
|
||||
|
||||
Map<String, Object> map = MapHelper.parser(data);
|
||||
int turnClientId = (int) map.get("nextClientId");
|
||||
|
||||
if(turnClientId == robot.getId()) {
|
||||
ServerEventListener.get(ServerEventCode.CODE_GAME_LANDLORD_ELECT).call(robot, "TRUE");
|
||||
if(room.getLastSellClient() == robot.getId()) {
|
||||
|
||||
}else {
|
||||
PokerSell lastPokerShell = room.getLastPokerShell();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user