1. 08 Dec, 2011 1 commit
    • Sam Moore's avatar
      Modified manager program, updated website · 17a20de4
      Sam Moore authored
      Major changes: Added simple GUI for human players
      Setup phase doesn't use GUI yet (uses a default if -g enabled).
      Click in the general region of where you want to select/move pieces.
      
      Modified Board::Draw to allow for showing of already revealed pieces,
      but not all pieces. Used to make human player GUI nicer (hides AI pieces).
      
      Modified -t switch to allow for "infinite" stall_time
      (wait for user to press enter)
      
      Changed website. Removed protocol description and linked to manual.txt.
      Added screenshot to make things slightly more exciting.
      Updated manual.txt
      
      Minor changes to simulate.py (output)
      
      TODO:
      Fix segmentation fault found in manager program
      It occurs just before exit. Memory error in the cleanup process?
      ANNOYING!
      
      Still have to bring myself to take the time to finish setting up that vm...
      Need to talk to a non-hostile wheel member about security. I don't want my vm to take out our network or something.
      
      Preferably I don't even want the vm to be compromised, regardless of the rest of ucc.
      So much I don't know about servers/linux...
      
      Need to stop staying up past midnight...
      17a20de4
  2. 07 Dec, 2011 1 commit
  3. 03 Dec, 2011 2 commits
    • Sam Moore's avatar
      More adding of pointless crap to manager · b563784f
      Sam Moore authored
      -f option to allow replaying of games output to files with -o
      -m option to enforce max number of turns (default 5000) before a DRAW is called
      -p to print a colourful representation of the board to stdout
      
      Yes. I now have both graphics AND pretty coloured terminal escape codes.
      Why did I do this??????????????
      b563784f
    • Sam Moore's avatar
      Revamped manager program and added manual page · 4a3c0478
      Sam Moore authored
      Seperated controllers into AI and human controllers, which inherit from the same base class
      Using "human" as an argument instead of an AI program will allow human player. However, the human player has to use the CLI.
      
      I have tried playing a few games, and it is incredibly annoying using the CLI (especially when each turn was printed to stdout - now suppressed).
      Usually I accidentally enter the wrong coordinates, or spend 30 seconds trying to work out the coordinates of a piece.
      Then when I switch the focus, the SDL window goes blank, and I don't know what the hell is going on.
      In conclusion: Should probably add GUI for human players!
      
      Created Game class to manage playing the game, rather than hacking everything into main.cpp
      Added argument switches for timeouts, graphics, output file, help, allowing illegal moves, revealing colours etc
      Added result lines (output who actually wins... amazing!) The massive spamming output that used to be printed is suppressed (enable with -o stdout/file).
      
      Created manual.txt which is the manual page for stratego (the manager program).
      stratego --help will display the page (using "less" - should probably fix for systems without "less").
      
      Changed tokens used for pieces from alphabet characters to digits for the ranked pieces, 's' for the Spy, 'B' for Bombs and 'F' for the Flag.
      This makes things clearer. The Spy would be "10", except thats 2 characters, which is a bit awkward!
      Didn't change the order of the enum, because thats just asking for trouble and besides, it works.
      Changed stratego to output the characters for the piece, instead of an integer rank (except for Flag, Bomb and Spy, no difference).
      
      Need to handle situations where a player has lost all their mobile pieces. Do they lose?
      Currently they will be forced to make an illegal move, and the other player wins by "default".
      
      Found mistake in forfax move score calculation that lead to moves having negative scores,
      and hence occasionally an illegal move would be chosen as more valuable than legal moves.
      Probably fixed. Illegal moves now score -1, so should NEVER be made! Ironically the change seemed to decrease forfax's performance against dummy.
      Forfax still seems to make really stupid moves, and I can't see why. Occasionally it does something smart
      (attacks Marshal with Spy just after the Marshal reveals itself), but I'm not sure how often these are coincidences.
      Even with the devaluing of moves that don't end in combat, Forfax still gets into long cycles of repeated paths with no purpose.
      And Forfax NEVER attacks Bombs or the Flag... even if thats all the enemy has, and even if the attacking piece would be a miner.
      
      Updated web page. Considering replacing Protocol Description as is with that written for manual.txt, which I feel is clearer.
      
      Need to make next git commit message shorter...
      4a3c0478
  4. 02 Dec, 2011 1 commit
    • Sam Moore's avatar
      Fixed "forfax" sample AI · 53a66690
      Sam Moore authored
      Forfax now plays a fairly mediocre game of Stratego
      He usually beats the dummy AI. Usually. After a while.
      
      Sometimes he gets stuck in a loop where he repeats the same moves over and over again.
      Sometimes he attempts to move bombs or the flag (???)
      He also never actually captures the flag; he just destroys all the enemy pieces before going into a loop.
      This is probably due to the movement value being very low for moving over pieces that are likely to be bombs
      And when all mobile pieces are destroyed, the remainder are seen to be likely to be bombs.
      
      The segfault was caused by much stupidity involving a for loop in Board::ForgetPiece and the continue statement
      Changed to a while loop to fix.
      
      Since Forfax works (Although it plays pretty badly) I will probably move onto other things for a while.
      53a66690
  5. 01 Dec, 2011 1 commit
    • Sam Moore's avatar
      Mostly messing with "forfax" AI · 041c37d1
      Sam Moore authored
      It would be nice to have an AI that doesn't segfault.
      
      Currently segfault caused by Board::ForgetPiece.
      valgrind outputs a lot of wierd crap about std::vector and uninitialised values
      Uninitialised values created by std::vector::push_back()
      All I am pushing is a simple pointer (Piece*), so I don't know WHY uninitialised values happen...
      The std::list used in MakeMove is somehow using the same memory as the std::vectors of the board, which is causing invalid reads
      Stupid, stupid stdlib.
      
      I think that once that is fixed, forfax is pretty much done. I'd like to see how well it plays, but... segfaults.
      
      I also fixed dummy to take into account the modified turn protocol which prints piece ranks. dummy just reads them and ignores them.
      
      I plan to make the manager program more useful
      	- Enable human players
      	- Add command line arguments for things like timeouts, graphics on/off etc
      	- Read a game from a file (so that games can be viewed after they are run)
      I need to go through the manager program carefully and make sure that the way AI programs quit actually works
      Ideally the AI program has a short period to exit gracefully before it is killed
      I think for some reason the AI program always just gets killed.
      
      At some point I need to setup a VM for this. I should probably do that.
      
      I also might change minor things like the tokens (from random characters to digits + a few characters) and the internal ordering of the enum Piece::Type
      041c37d1
  6. 30 Nov, 2011 1 commit
    • Sam Moore's avatar
      Modified Turn Response Protocol, added handling for SIGPIPE, changed placeholder images · 2ab27eb6
      Sam Moore authored
      The "outcome" of a move is now listed as:
      
      TYPE [ATTACKER_RANK] [DEFENDER_RANK]
      
      Where ATTACKER_RANK and DEFENDER_RANK will be present if TYPE is one of: KILLS, DIES, BOTHDIE, and indicate the ranks of the pieces involved.
      This involved adding a class MovementResult, which stores the ranks of pieces in addition to an enum, replacing the enum Board::MovementResult
      
      The sample agent "forfax" was causing broken pipes, which caused the manager program to exit.
      I added a handler for SIGPIPE in manager/main.cpp to ensure that the manager program reports a DEFAULT victory to the other AI, and exits gracefully.
      However, I still don't know WHY forfax causes broken pipes, but hopefully its a problem with forfax and not with the manager program.
      
      I edited the images used by the graphical display to show the ordered ranks of the pieces, rather than some obscure characters.
      Unfortunately I have just realised that the enum used for Piece::Type stores ranks in the wrong order.
      In the actual game, LOWER numbers are better, in my enum, HIGHER numbers are better.
      To make things more confusing, I made the printed ATTACKER_RANK and DEFENDER_RANK correspond to the traditional numbering, not the enum numbering...
      2ab27eb6
  7. 29 Nov, 2011 1 commit