The Code-Bin
Links
Home
Add your code!
All Listings
About
Latest Entry
Featured Scripts
Author's Website
Latest Entries
FFMPEG Thumbnail Scr...
PHP, 0.8KB
Jul. 29, 10:24pm
John
Z80 Assembler, 190 bytes
Feb. 17, 3:36am
John
Z80 Assembler, 176 bytes
Sep. 13, 2:19am
John
Z80 Assembler, 77 bytes
Sep. 13, 2:18am
John
Z80 Assembler, 209 bytes
Sep. 13, 2:17am
untitled C++ Code
Posted by: dave | June 29, 2010 @ 2:58am
C++ Code
[
Download
]
void RTSSearch::search() { // create the initial state GameStateNode g(true, this, data); LOOP_BITS (g.getLegalActions(), action) { printf("%s\n", data->action_strings[action].c_str()); } open_list.push_back(g); int nodes = 0; bool solutionFound = false; int winningFrame = 1000000; GameStateNode * winner; while (true) { if (++nodes % 1000 == 0) printf("Nodes searched: %d\n", nodes); // if we have met the goal, we're good if (g.meetsGoal()) { solutionFound = true; //printf("\n\nGOAL MET!\n\n"); //g.printData(); if (g.currentFrame < winningFrame) { winningFrame = g.currentFrame; winner = &g; g.printData(); } } if (g.currentFrame < winningFrame) { // otherwise, generate the children and add them to the open list // for each of the bits in the bitmask LOOP_BITS(g.getLegalActions(), nextAction) { // copy the current state to a child state GameStateNode child(g); child.parent = &g; // perform the current action child.doAction((ZergData::zerg_action)nextAction); // search the child state open_list.push_back(child); } } if (++search_index < open_list.size()) g = open_list[search_index]; else break; } if (solutionFound) { winner->printData(); } }
Syntax Highlighting
[
Open in new window
]
Author Comments
none
Rating
4.45 / 8
42 Votes
http://codebin.yi.org/718
page generated in 0.00 seconds