diff --git a/src/main/java/models/Algo.java b/src/main/java/models/Algo.java index 996140c..391cb4b 100644 --- a/src/main/java/models/Algo.java +++ b/src/main/java/models/Algo.java @@ -10,13 +10,23 @@ private LoseA loseA; private HandsA handsA; private Deck deck; + private SucceedDrawA succeedDrawA; + private SucceedDrawB succeedDrawB; + private SucceedSelectA succeedSelectA; + private SucceedSelectB succeedSelectB; int turnCount=0; public Algo() { + ///モデル生成分 loseB = new LoseB(); handsB = new HandsB(loseB); loseA = new LoseA(); handsA = new HandsA(loseA); deck = new Deck(); + succeedDrawA = new SucceedDrawA(handsB,deck,handsA); + succeedDrawB = new SucceedDrawB(deck,handsB,handsA); + succeedSelectA = new SucceedSelectA(handsB,handsA); + succeedSelectB = new SucceedSelectB(handsA,handsB); + //追加分 deck.reset(DECK_COUNT); for(int i=0;i<2;i++){ handsA.getValue().add(deck.head()); @@ -50,12 +60,33 @@ this.handsB.selectB(guess, attacker, a, target); this.handsA.selectB(guess, attacker, a, target); } + public void inputSelectA(int guess, int attacker, int target) { + this.succeedSelectA.inputSelectA(guess, attacker, target); + } + public void inputDrawA(int guess, List> b, int target) { + this.succeedDrawA.inputDrawA(guess, b, target); + } + public void inputDrawB(int guess, List> a, int target) { + this.succeedDrawB.inputDrawB(guess, a, target); + } + public void inputSelectB(int guess, int attacker, int target) { + this.succeedSelectB.inputSelectB(guess, attacker, target); + } private void countUpTurn(){ turnCount++; } - public List> getDeck() { + public Map.Entry> getSucceedSelectB() { + return succeedSelectB.getValue(); + } + public Map.Entry> getSucceedSelectA() { + return succeedSelectA.getValue(); + } + public List getDeck() { return deck.getValue(); } + public Map.Entry getSucceedDrawB() { + return succeedDrawB.getValue(); + } public boolean getLoseA() { return loseA.getValue(); } @@ -68,4 +99,7 @@ public List> getHandsA() { return handsA.getValue(); } + public Map.Entry getSucceedDrawA() { + return succeedDrawA.getValue(); + } } \ No newline at end of file diff --git a/src/main/java/models/Algotest.java b/src/main/java/models/Algotest.java new file mode 100644 index 0000000..94de59f --- /dev/null +++ b/src/main/java/models/Algotest.java @@ -0,0 +1,65 @@ +package models; + +import java.util.*; + +public class Algotest { + private LoseB loseB; + private HandsB handsB; + private LoseA loseA; + private HandsA handsA; + private Deck deck; + private SucceedDrawA succeedDrawA; + private SucceedDrawB succeedDrawB; + private SucceedSelectA succeedSelectA; + private SucceedSelectB succeedSelectB; + public Algotest() { + loseB = new LoseB(); + handsB = new HandsB(loseB); + loseA = new LoseA(); + handsA = new HandsA(loseA); + deck = new Deck(); + succeedDrawA = new SucceedDrawA(handsB,deck,handsA); + succeedDrawB = new SucceedDrawB(deck,handsB,handsA); + succeedSelectA = new SucceedSelectA(handsB,handsA); + succeedSelectB = new SucceedSelectB(handsA,handsB); + } + public void inputSelectA(int guess, int attacker, int target) { + this.succeedSelectA.inputSelectA(guess, attacker, target); + } + public void inputDrawA(int guess, List> b, int target) { + this.succeedDrawA.inputDrawA(guess, b, target); + } + public void inputDrawB(int guess, List> a, int target) { + this.succeedDrawB.inputDrawB(guess, a, target); + } + public void inputSelectB(int guess, int attacker, int target) { + this.succeedSelectB.inputSelectB(guess, attacker, target); + } + public Map.Entry> getSucceedSelectB() { + return succeedSelectB.getValue(); + } + public Map.Entry> getSucceedSelectA() { + return succeedSelectA.getValue(); + } + public List getDeck() { + return deck.getValue(); + } + public Map.Entry getSucceedDrawB() { + return succeedDrawB.getValue(); + } + public boolean getLoseA() { + return loseA.getValue(); + } + public boolean getLoseB() { + return loseB.getValue(); + } + public List> getHandsB() { + return handsB.getValue(); + } + public List> getHandsA() { + return handsA.getValue(); + } + public Map.Entry getSucceedDrawA() { + return succeedDrawA.getValue(); + } +} \ No newline at end of file diff --git a/src/main/java/models/Deck.java b/src/main/java/models/Deck.java index 5aa6f48..c61c677 100644 --- a/src/main/java/models/Deck.java +++ b/src/main/java/models/Deck.java @@ -3,6 +3,8 @@ import java.util.*; public class Deck { + private Map.Entry succeedDrawB; + private Map.Entry succeedDrawA; private List> value = new ArrayList<>(); public void drawB(int guess, List> a, List> d, int target) { this.value = this.value.subList(1, this.value.size()); @@ -27,4 +29,12 @@ public List> getValue() { return value; } + public void updateSucceedDrawB(Map.Entry succeedDrawB) { + this.succeedDrawB = succeedDrawB; + value = this.value.subList(1, this.value.size()); + } + public void updateSucceedDrawA(Map.Entry succeedDrawA) { + this.succeedDrawA = succeedDrawA; + value = this.value.subList(1, this.value.size()); + } } \ No newline at end of file diff --git a/src/main/java/models/HandsA.java b/src/main/java/models/HandsA.java index 63a1ea2..27ee963 100644 --- a/src/main/java/models/HandsA.java +++ b/src/main/java/models/HandsA.java @@ -3,6 +3,10 @@ import java.util.*; public class HandsA { + private Map.Entry> succeedSelectA; + private Map.Entry> succeedSelectB; + private Map.Entry succeedDrawB; + private Map.Entry succeedDrawA; private LoseA loseA; private List> value = new ArrayList>(); public HandsA(LoseA loseA) { @@ -59,4 +63,56 @@ public List> getValue() { return value; } + + public void updateSucceedSelectA(Map.Entry> succeedSelectA) { + this.succeedSelectA = succeedSelectA; + List> temp_if3; + if (succeedSelectA.getKey()) { + temp_if3 = this.value; + } else { + this.value.set(succeedSelectA.getValue().getKey(),new AbstractMap.SimpleEntry<>(this.value.get(succeedSelectA.getValue().getValue()).getKey(), true)); + temp_if3 = this.value; + } + value = temp_if3; + this.loseA.updateHandsA(value); + } + public void updateSucceedSelectB(Map.Entry> succeedSelectB) { + this.succeedSelectB = succeedSelectB; + List> temp_if4; + if (succeedSelectB.getKey()) { + this.value.set(succeedSelectB.getValue().getKey(),new AbstractMap.SimpleEntry<>(this.value.get(succeedSelectB.getValue().getKey()).getKey(), true)); + temp_if4 = this.value; + } else { + temp_if4 = this.value; + } + value = temp_if4; + this.loseA.updateHandsA(value); + } + public void updateSucceedDrawB(Map.Entry succeedDrawB, List> deck) { + this.succeedDrawB = succeedDrawB; + List> temp_if6; + if (succeedDrawB.getKey()) { + this.value.set(succeedDrawB.getValue(),new AbstractMap.SimpleEntry<>(this.value.get(succeedDrawB.getValue()).getKey(), true)); + temp_if6 = this.value; + } else { + temp_if6 = this.value; + } + value = temp_if6; + this.loseA.updateHandsA(value); + } + public void updateSucceedDrawA(Map.Entry succeedDrawA, List> deck) { + this.succeedDrawA = succeedDrawA; + List> temp_if7; + if (succeedDrawA.getKey()) { + this.value.add(0, new AbstractMap.SimpleEntry<>(deck.get(0).getKey(), false)); + this.value.sort(Comparator.comparing(Map.Entry::getKey)); + temp_if7 = this.value; + } else { + this.value.add(0, new AbstractMap.SimpleEntry<>(deck.get(0).getKey(), true)); + this.value.sort(Comparator.comparing(Map.Entry::getKey)); + temp_if7 = this.value; + } + value = temp_if7; + this.loseA.updateHandsA(value); + } } \ No newline at end of file diff --git a/src/main/java/models/HandsB.java b/src/main/java/models/HandsB.java index 04a9649..71745ed 100644 --- a/src/main/java/models/HandsB.java +++ b/src/main/java/models/HandsB.java @@ -3,6 +3,10 @@ import java.util.*; public class HandsB { + private Map.Entry succeedDrawB; + private Map.Entry> succeedSelectA; + private Map.Entry succeedDrawA; + private Map.Entry> succeedSelectB; private LoseB loseB; private List> value = new ArrayList>(); public HandsB(LoseB loseB) { @@ -60,4 +64,55 @@ public List> getValue() { return value; } + public void updateSucceedDrawB(Map.Entry succeedDrawB, List> deck) { + this.succeedDrawB = succeedDrawB; + List> temp_if0; + if (succeedDrawB.getKey()) { + this.value.add(0, new AbstractMap.SimpleEntry<>(deck.get(0).getKey(), false)); + this.value.sort(Comparator.comparing(Map.Entry::getKey)); + temp_if0 = this.value; + } else { + this.value.add(0, new AbstractMap.SimpleEntry<>(deck.get(0).getKey(), true)); + this.value.sort(Comparator.comparing(Map.Entry::getKey)); + temp_if0 = this.value; + } + value = temp_if0; + this.loseB.updateHandsB(value); + } + public void updateSucceedSelectA(Map.Entry> succeedSelectA) { + this.succeedSelectA = succeedSelectA; + List> temp_if1; + if (succeedSelectA.getKey()) { + this.value.set(succeedSelectA.getValue().getKey(),new AbstractMap.SimpleEntry<>(this.value.get(succeedSelectA.getValue().getKey()).getKey(), true)); + temp_if1 = this.value; + } else { + temp_if1 = this.value; + } + value = temp_if1; + this.loseB.updateHandsB(value); + } + public void updateSucceedDrawA(Map.Entry succeedDrawA, List deck) { + this.succeedDrawA = succeedDrawA; + List> temp_if2; + if (succeedDrawA.getKey()) { + this.value.set(succeedDrawA.getValue(),new AbstractMap.SimpleEntry<>(this.value.get(succeedDrawA.getValue()).getKey(), true)); + temp_if2 = this.value; + } else { + temp_if2 = this.value; + } + value = temp_if2; + this.loseB.updateHandsB(value); + } + public void updateSucceedSelectB(Map.Entry> succeedSelectB) { + this.succeedSelectB = succeedSelectB; + List> temp_if5; + if (succeedSelectB.getKey()) { + temp_if5 = this.value; + } else { + this.value.set(succeedSelectB.getValue().getKey(),new AbstractMap.SimpleEntry<>(this.value.get(succeedSelectB.getValue().getValue()).getKey(), true)); + temp_if5 = this.value; + } + value = temp_if5; + this.loseB.updateHandsB(value); + } } \ No newline at end of file diff --git a/src/main/java/models/SucceedDrawA.java b/src/main/java/models/SucceedDrawA.java new file mode 100644 index 0000000..0bce37a --- /dev/null +++ b/src/main/java/models/SucceedDrawA.java @@ -0,0 +1,26 @@ +package models; + + +import java.util.*; + +public class SucceedDrawA { + private HandsB handsB; + private Deck deck; + private HandsA handsA; + private Map.Entry value; + public SucceedDrawA(HandsB handsB, Deck deck, HandsA handsA) { + this.handsB = handsB; + this.deck = deck; + this.handsB = handsB; + } + public void inputDrawA(int guess, List> b, int target) { + this.value = new AbstractMap.SimpleEntry<>((handsB.getValue().get(target).getKey()==guess), target); + List deck = this.deck.getValue(); + this.handsB.updateSucceedDrawA(value, deck); + this.deck.updateSucceedDrawA(value); + this.handsA.updateSucceedDrawA(value, deck); + } + public Map.Entry getValue() { + return value; + } +} \ No newline at end of file diff --git a/src/main/java/models/SucceedDrawB.java b/src/main/java/models/SucceedDrawB.java new file mode 100644 index 0000000..28a6475 --- /dev/null +++ b/src/main/java/models/SucceedDrawB.java @@ -0,0 +1,25 @@ +package models; + +import java.util.*; + +public class SucceedDrawB { + private Deck deck; + private HandsB handsB; + private HandsA handsA; + private Map.Entry value; + public SucceedDrawB(Deck deck, HandsB handsB, HandsA handsA) { + this.deck = deck; + this.handsB = handsB; + this.handsA = handsA; + } + public void inputDrawB(int guess, List> a, int target) { + this.value = new AbstractMap.SimpleEntry<>((handsA.getValue().get(target).getKey()==guess), target); + this.deck.updateSucceedDrawB(value); + List deck = this.deck.getValue(); + this.handsB.updateSucceedDrawB(value, deck); + this.handsA.updateSucceedDrawB(value, deck); + } + public Map.Entry getValue() { + return value; + } +} \ No newline at end of file diff --git a/src/main/java/models/SucceedSelectA.java b/src/main/java/models/SucceedSelectA.java new file mode 100644 index 0000000..4ee946d --- /dev/null +++ b/src/main/java/models/SucceedSelectA.java @@ -0,0 +1,21 @@ +package models; + +import java.util.*; + +public class SucceedSelectA { + private HandsB handsB; + private HandsA handsA; + private Map.Entry> value; + public SucceedSelectA(HandsB handsB, HandsA handsA) { + this.handsB = handsB; + this.handsA = handsA; + } + public void inputSelectA(int guess, int attacker, int target) { + this.value = new AbstractMap.SimpleEntry<>((handsB.getValue().get(target).getKey()==guess), new AbstractMap.SimpleEntry<>(target,attacker)); + this.handsB.updateSucceedSelectA(value); + this.handsA.updateSucceedSelectA(value); + } + public Map.Entry> getValue() { + return value; + } +} \ No newline at end of file diff --git a/src/main/java/models/SucceedSelectB.java b/src/main/java/models/SucceedSelectB.java new file mode 100644 index 0000000..45506d9 --- /dev/null +++ b/src/main/java/models/SucceedSelectB.java @@ -0,0 +1,21 @@ +package models; + +import java.util.*; + +public class SucceedSelectB { + private HandsA handsA; + private HandsB handsB; + private Map.Entry> value; + public SucceedSelectB(HandsA handsA, HandsB handsB) { + this.handsA = handsA; + this.handsB = handsB; + } + public void inputSelectB(int guess, int attacker, int target) { + this.value = new AbstractMap.SimpleEntry<>((handsA.getValue().get(target).getKey()==guess), new AbstractMap.SimpleEntry<>(target,attacker)); + this.handsA.updateSucceedSelectB(value); + this.handsB.updateSucceedSelectB(value); + } + public Map.Entry> getValue() { + return value; + } +} \ No newline at end of file