Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • francesco-bariatti/pingouins
  • Samuel.Felton/pingouins
  • Lucas.Clement/pingouins
3 results
Show changes
#ifndef __TEST_MINMAX_HPP__
#define __TEST_MINMAX_HPP__
namespace minmax
{
class test_minmax
{
void play();
template <typename Game>
int select_move(Game& game);
public:
test_minmax();
};
}
#endif
#!/usr/bin/env python3
#-*- encoding: utf-8 -*-
import drawState
import subprocess
import json
import os
if __name__ == "__main__":
programname = os.path.join(os.path.dirname(__file__), "../bin/theturk")
program = subprocess.Popen(programname, stdin = subprocess.PIPE, stdout = subprocess.PIPE, universal_newlines = True, bufsize = 1)
try:
program.stdin.write("h\n")
while True:
#READ
readloop = True
comments = []
json_data = ""
brackets_count = 0
while readloop:
line = program.stdout.readline()
#print(line)
line = line.replace("who's first? (h)uman/(c)omputer ", "")
line = line.replace("Red move: ", "")
line = line.replace("Blue move: ", "")
if line.startswith("{"): #Reading json
json_data = line
else:
comments.append(line)
if line == "\n":
readloop = False
#PRINT STATE
print("Comments: {}".format(''.join(comments)))
state = json.loads(json_data)
drawState.drawBitboard(state["bitboards"]["onefish"],state["bitboards"]["twofish"],state["bitboards"]["threefish"])
print("Red penguins (Red score: {}, Total moves: {} [0..{}])".format(state["score"]["red"], state["nb_moves"]["red"], state["nb_moves"]["red"]-1))
for i in range(4):
drawState.drawPenguin(state["penguins"]["red"][i])
print("Blue penguins (Blue score: {}, Total moves: {} [0..{}])".format(state["score"]["blue"], state["nb_moves"]["blue"], state["nb_moves"]["blue"] -1))
for i in range(4):
drawState.drawPenguin(state["penguins"]["blue"][i])
#PLAY NEXT MOVE
if state["current_player"] == "Red":
move = input("Enter Red move: ")
else:
move = input("Enter Blue move: ")
program.stdin.write(move+"\n")
program.stdin.flush()
except BrokenPipeError:
print("Game end")
except KeyboardInterrupt:
print("\nMay the fish be with you.")
finally:
program.kill()